oracle 创建用户,表空间,授权,表,序列,同义词等

1.创建用户

 create user username identified by password;
    username:用户名
    password:  密码

--创建用户 apps, 密码 apps
create user apps identified by apps;

2.创建表空间

create tablespace tablespacename datafile d:\data.dbf size xxxm;
    tablespacename:表空间的名字
    d:\data.dbf:表空间的存储位置
    xxx表空间的大小,m单位为兆(M)
例:创建表空间 cux_data ,位置 D:\app\chengqian\oradata\orcl\cux_data.dbf,大小为100M.
create tablespace cux_data datafile D:\app\chengqian\oradata\orcl\cux_data.dbf Size 100M;

3.授权和移除权限

grant connect to user_name;
grant create indextype to user_name;
grant create job to user_name;
grant create materialized view to user_name;
grant create procedure to user_name;
grant create public synonym to user_name;
grant create sequence to user_name;
grant create session to user_name;
grant create table to user_name;
grant create trigger to user_name;
grant create type to user_name;
grant create view to user_name;
grant unlimited tablespace to user_name;
alter user user_name quota unlimited on tbs_name;
--常用的权限
--常用的系统权限集合有以下三个:
--CONNECT(基本的连接), RESOURCE(程序开发), DBA(数据库管理)

--常用的数据对象权限有以下五个:
--ALL ON 数据对象名, SELECT ON 数据对象名, UPDATE ON 数据对象名,
--DELETE ON 数据对象名, INSERT ON 数据对象名, ALTER ON 数据对象名

GRANT CONNECT, RESOURCE TO 用户名;
GRANT SELECT ON 表名 TO 用户名;
GRANT SELECT, INSERT, DELETE ON表名 TO 用户名1, 用户名2;


grant execute on apps.Cux_Mrp_Material_Sd_Pub to APPSQUERY;
--revoke 回收权限的使用和grant类似
revoke execute on apps.Cux_Mrp_Material_Sd_Pub from APPSQUERY;

REVOKE CONNECT, RESOURCE FROM 用户名;
REVOKE SELECT ON 表名 FROM 用户名;
REVOKE SELECT, INSERT, DELETE ON 表名 FROM 用户名1, 用户名2;

4.创建表

create table cux.cux_test_table_all
(
  id                 NUMBER not null,
  organization_id    NUMBER not Null,
  category_1         Number not null,
  category_2         Number not Null,
  top_number         Number not Null,
  down_number        Number not Null,
  lot_ratio          Number not Null,
  remark             VARCHAR2(20),
  approved_id        VARCHAR2(10),
  approved_time      VARCHAR2(240),
  approved_status    VARCHAR2(240),
  creation_date      DATE default sysdate not null,
  created_by         NUMBER default -1 not null,
  last_updated_by    NUMBER default -1 not null,
  last_update_date   DATE default sysdate not null,
  last_update_login  NUMBER,
  attribute_category VARCHAR2(30),
  attribute1         VARCHAR2(240),
  attribute2         VARCHAR2(240),
  attribute3         VARCHAR2(240),
  attribute4         VARCHAR2(240),
  attribute5         VARCHAR2(240),
  attribute6         VARCHAR2(240),
  attribute7         VARCHAR2(240),
  attribute8         VARCHAR2(240),
  attribute9         VARCHAR2(240),
  attribute10        VARCHAR2(240),
  attribute11        VARCHAR2(240),
  attribute12        VARCHAR2(240),
  attribute13        VARCHAR2(240),
  attribute14        VARCHAR2(240),
  attribute15        VARCHAR2(240)
);

5.创建序列

create sequence cux.CUX_WIP_CATEGORY_RATIO_s
minvalue 1
maxvalue 999999999999999999999999
start with 1
increment by 1
cache 10;

6.创建同义词

Create Synonym CUX_WIP_CATEGORY_RATIO For  CUX.CUX_WIP_CATEGORY_RATIO;

以上,除使用命令创建,还可以在plsql develope 等工具中创建和授权

 


oracle 创建用户,表空间,授权,表,序列,同义词等

上一篇:Mysql索引优化攻略(全)


下一篇:Mysql中where条件自动类型转换的坑