1.应用oracle的Database Configuration Assistant建立数据库所有用户一个密码(admin)库名database
2.sqlplus conn sys/admin@database as sysdba
成功连接后
3.执行
Create user username identified by admin;
Grant connect,resource to username;
4.建立表空间
CREATE TABLESPACE ts_User BLOCKSIZE 8192 DATAFILE 'e:\ORACLE\PRODUCT\10.2.0\ORADATA\database\ts_User.dbf'
SIZE 300m AUTOEXTEND ON NEXT 200m MAXSIZE unlimited EXTENT MANAGEMENT LOCAL AUTOALLOCATE ONLINE
PERMANENT SEGMENT SPACE MANAGEMENT AUTO;
5.设置用户username对表空间 ts_user的权限
alter user username quota unlimited on ts_user;
6.以用户username登录并建立表,表分区及索引
create table table_user
(
id number not null,
age date,
time date,
)
partition by range(time)
(partition p1 values less than(to_date('2010-9-1','yyyy-mm-dd')) tablespace ts_User,
partition p2 values less than(to_date('2010-10-1','yyyy-mm-dd')) tablespace ts_User,
partition p120 values less than (maxvalue) tablespace ts_User
);
alter table table_user add constraint pk_id primary key(id) using index tablespace ts_user; --增加主键约束并指定表空间
create index time_local on table_user(time) local; --一般索引分布在表分区上
create bitmap index age_local on table_user(age) local; --位图索引 本地索引分布在表分区上