用SQL语句创建表空间

使用SQL语句进行创建. 

1.创建表空间 

-- 公共模块表空间 
create tablespace cctc_core     
logging     
datafile   
'/ORACLE/PRODUCT/10.2.0/ORADATA/cctchdcq/cctc_core.dbf'     
size 100m    
autoextend on next  10m     
extent management local     
segment space management auto 
/
-- 业务表空间 
create tablespace cctc_operation     
logging     
datafile   
'/ORACLE/PRODUCT/10.2.0/ORADATA/cctchdcq/cctc_operation.dbf'     
size 100m     
autoextend on next  10m     
extent management local     
segment space management auto 
/ 
2.创建用户并分配权限 

-- Create the user  
create user HDCQ   
default tablespace CCTC_CORE--默认表空间   
temporary tablespace TEMP   
profile DEFAULT   
quota unlimited on cctc_core--设定用户的表空间   
quota unlimited on cctc_operation;--设定用户的表空间 
-- Grant/Revoke role privileges 设定用户权限 
grant connect to HDCQ with admin option; 
grant dba to HDCQ with admin option; 
grant resource to HDCQ with admin option; 
-- Grant/Revoke system privileges 表空间的系统权限 
grant unlimited tablespace to HDCQ with admin option;  
3.创建表 

create table  t_organization  (
-- 主键
org_pk             number(10,0)                not null,     
-- 父主键     
father_org_pk      number(10,0) default 0,     
-- 组织机构名称     
org_name           varchar2(100)             not null,     
-- 创建时间     
create_time        varchar2(50) default    
to_char(sysdate,'yyyy-MM-dd HH:mm:ss')  not null,     
constraint pk_t_organization primary key (org_pk)
) 
tablespace cctc_core
/
create sequence seq_organization     
start with 140     
increment by 1     
maxvalue   9999999999     
minvalue   1     
cycle
/ 
-- ============================================= 
--用途:创建客户来电表 
-- 表名:t_customer  
-- ============================================= 
create table t_customer  
( 
--主键    
customer_pk           raw(16)                      not null,    
--客户名称    
customer_name   varchar2(200)        not null,    
--客户电话    
customer_phone        varchar2(100)                 not null,    
--创建人    
create_user_pk        int                   not null,    
--创建时间    
create_time varchar2(50) default 
to_char(sysdate,'yyyy-MM-dd HH:mm:ss') not null,     
constraint pk_t_customer primary key (customer_pk) 
)
tablespace cctc_operation
/ 




你可能感兴趣的:(Oracle,oracle,表空间,SQL)