二、创建表空间、回滚段、用户、表的语法
1、创建表空间(这是在建数据库时的第一步要做的工作,表空间好比容器,将数据库的各种东西包含在里面)
CREATE TABLESPACE test DATAFILE '/dev/test_name1' SIZE 1000M, '/dev/test_name2' SIZE 1000M , '/dev/test_name3' SIZE 1000M
DEFAULT STORAGE ( INITIAL 64K NEXT 64K MAXEXTENTS UNLIMITED PCTINCREASE 50 );
注意:这里没有对表空间的扩展进行限制。
2、修改表空间
alter TABLESPACE ts_name1 add DATAFILE '/dev/name4' SIZE 1000M;
3、回滚段
CREATE ROLLBACK SEGMENT "RStest" TABLESPACE "Test_name"
STORAGE ( INITIAL 16M NEXT 16M MAXEXTENTS UNLIMITED);
注意不要建不同的大小的回滚段,因为ORACLE不会自己挑选和需要最相符的回滚段
4、创建用户和授权
CREATE USER test_user IDENTIFIED BY test_user
DEFAULT TABLESPACE Test_name1 TEMPORARY TABLESPACE Test_name2;
GRANT CONNECT TO test_user;
GRANT DBA TO test_user;
GRANT resource TO test_user;
5、创建表
create table test_name1
(
a NUMBER(10) not null,
b NUMBER(10) null ,
c NUMBER(3) defalut 0,
d number(3) not null ,
constraint PK_ test_user primary key (a)
using index
tablespace test_name1
storage
(
initial 1m
next 1m
pctincrease 0
)
)
pctfree 10
tablespace test_name1
storage
(
initial 1m
next 1m
pctincrease 0
)
partition by range(d)
(partition part000 values less than (1) tablespace test_name1,
partition part001 values less than (2) tablespace test_name1,
)
/
6、创建索引
create index id_tablename1 on test_name1 (f2)
tablespace ts_name
storage
(
initial 500k
next 500k
pctincrease 0
)
