zgxzowen 2016-03-25
1.数据库空间
create tablespace danny_space datafile 'C:\oraclexe\app\oracle\oradata\XE\danny_space_data.dbf' size 500M;
SELECT tablespace_name, SUM(bytes) bytes, MAX(bytes) largest FROM dba_free_space Group By Tablespace_Name; select tablespace_name from dba_tablespaces;
你的数据库路径下有个oradata的文件夹里面放着oracle某个数据库空间文件,数据库资料在这里。
2.空间下建立用户
createuserzhuidentifiedbyzhudefaulttablespacedanny_space;
3.对用户进行授权
grantconnect,resourcetonews;--表示把connect,resource权限授予news用户
grantdbatonews;--表示把dba权限授予给news用户
grant dba to Zhu;
创建空间并且能自增空间
createtablespaceBTADATAdatafile'/home/app/oracle/oradata/ifp30/BTADATA.dbf'size100Mautoextendonnext50M;
删除表空间:
DROPTABLESPACEtable_spacenameINCLUDINGCONTENTSANDDATAFILES;
更改自动扩展属性
alterdatabasedatafile
'/home/app/oracle/oradata/oracle8i/sales01.dbf',
'/home/app/oracle/oradata/oracle8i/sales02.dbf'
'/home/app/oracle/oradata/oracle8i/sales01.dbf
autoextendoff;
为表空间增加数据文件:
altertablespacesalesadd
datafile'/home/app/oracle/oradata/oracle8i/sales02.dbf'size800M
autoextendonnext50M
maxsize1000M;
droptablespacexxxincludingcontentsanddatafiles
3.创建表
CREATE TABLE "ZHU"."GCFW_APPLICATION" ( "APPLICATION_ID" NUMBER NOT NULL ENABLE, "NAME" VARCHAR2(64 CHAR) NOT NULL ENABLE, "STATE" VARCHAR2(32 CHAR), "LOG_LEVEL" VARCHAR2(32 CHAR), "CREATED_BY" VARCHAR2(30) NOT NULL ENABLE, "UPDATED_AT" TIMESTAMP (6) WITH TIME ZONE, "UPDATED_BY" VARCHAR2(30), "CREATED_AT" TIMESTAMP (6) WITH TIME ZONE, "CREATED_FROM" VARCHAR2(100) DEFAULT SYS_CONTEXT('USERENV','HOST'), "UPDATED_FROM" VARCHAR2(100), CONSTRAINT "PK_1031" PRIMARY KEY ("APPLICATION_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS TABLESPACE "DANNY_SPACE" ENABLE ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 Nocompress Logging TABLESPACE "DANNY_SPACE"
创建表后可以再得到表的ddl
参数是类型,对象名,schema名(schema名就是user名)
SELECTDBMS_METADATA.GET_DDL('TABLE','GCFW_APPLICATION','ZHU')FROMDUAL;