`
steadyman
  • 浏览: 9534 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

创建表空间

阅读更多

1.创建临时表空间
create temporary tablespace website_temp
tempfile '/opt/u02/oradata/website/website_temp01.dbf'
size 50m autoextend on next 30m maxsize 2048m
extent management local;

2.创建数据表空间
create tablespace website_data
logging
datafile '/opt/u02/oradata/website/website_data01.dbf'
size 100m autoextend on next 50m maxsize 2048m
extent management local;

3.创建用户,并指定默认表空间。
create user website identified by website
default tablespace website_data
temporary tablespace website_temp;

4.给用户授权。
grant connect,resource to website;

 

eg:

-- Create the user
create user DBSHOPUSR
  identified by ""
  default tablespace SHOPSPACE
  temporary tablespace SHOPTMP
  profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to DBSHOPUSR;
grant resource to DBSHOPUSR;
-- Grant/Revoke system privileges
grant unlimited tablespace to DBSHOPUSR;

 

===============================================

 

create用户
  sql 代码
  
   1.Sql代码
  SQL> create user visiontv identified by visiontv default tablespace visiontv quota 10m on users;
  
   SQL> create user visiontv identified by visiontv default tablespace visiontv quota 10m on users;
  
  grant privilege
  sql 代码
  
   1. Sql代码
  SQL> grant connect,resource to visiontv;
  
  SQL> grant connect,resource to visiontv;
  
  create tablespace
  sql 代码
  
  Sql代码
  1. SQL> create tablespace visiontv datafile 'D:\DBServer\oracle\oradata\oradb01\vis
  2. iontv.ora' size 100m reuse default storage(initial 500k next 500k pctincrease 20
  3. );
  
   1. SQL> create tablespace visiontv datafile 'D:\DBServer\oracle\oradata\oradb01\vis
   2. iontv.ora' size 100m reuse default storage(initial 500k next 500k pctincrease 20
   3. );
  
  
  
  import后就可以用了。
  
  //
  
  建立用户到用户建表的步骤:
  Server
  建立:create user 用户名 identified by "密码";
  授权:grant create session to 用户名;
   grant create table to 用户名;
   grant create tablespace to 用户名;
   grant create view to 用户名;
  
  Client:
  建立表空间(一般建N个存数据的表空间和一个索引空间):
  create tablespace 表空间名
  datafile ' 路径(要先建好路径)\***.dbf ' size *M
  tempfile ' 路径\***.dbf ' size *M
  autoextend on --自动增长
  --还有一些定义大小的命令,看需要
  default storage(
  initial 100K,
  next 100k,
  );
  Server:
  授予用户使用表空间的权限:
  alter user 用户名 quota unlimited on 表空间;
  或 alter user 用户名 quota *M on 表空间;
  自此,才大功告成可以随意建表,运行SQL脚本!
  
  //1.建表空间
  
  Sql代码
  create tablespace OSDB datafile 'F:\oracle\oradata\glsqjz\OSDB.ora' size 100m reuse default storage(initial 500k next 500k pctincrease 20);
  
  create tablespace OSDB datafile 'F:\oracle\oradata\glsqjz\OSDB.ora' size 100m reuse default storage(initial 500k next 500k pctincrease 20);
  2.建用户
  
  Sql代码
  create user OSUSER identified by OSUSER
  
  create user OSUSER identified by OSUSER;//identified by 后面的是密码,前面的是用户名
  
  3.用户授权
  
  Sql代码
  grant resource,connect,RECOVERY_CATALOG_OWNER to OSUSER ;
  
  grant create table to OSUSER ;
  
  alter user OSUSER quota unlimited ON OSDB;
  
  alter user OSUSER default tablespace OSDB;
  
  grant resource,connect,RECOVERY_CATALOG_OWNER to OSUSER ;
  
  grant create table to OSUSER ;
  
  alter user OSUSER quota unlimited ON OSDB;
  
  alter user OSUSER default tablespace OSDB;
  4.删除表空间
  
  Sql代码
  DROP TABLESPACE TableSpaceName INCLUDING CONTENTS AND DATAFILES;
  
  DROP TABLESPACE TableSpaceName INCLUDING CONTENTS AND DATAFILES;
  5.删除用户
  
  Sql代码
  DROP USER User_Name CASCADE
  
  DROP USER User_Name CASCADE
  
  6.删除表的注意事项
  
  在删除一个表中的全部数据时,须使用Sql代码
  TRUNCATE TABLE 表名
  
  TRUNCATE TABLE 表名;因为用DROP TABLE,DELETE * FROM 表名时,TABLESPACE表空间该表的占用空间并未释放,反复几次DROP,DELETE操作后,该TABLESPACE上百兆的空间就被耗光了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics