Oracle笔记(1):建库学习

Oracle数据库建库过程:

1.创建用户

2.分配角色权限

3.建立表空间

4.新建表

5.添加、删除、修改、查询

6.数据库备份

7.数据库还原

今天学习Oracle建立一个数据库的基本操作,首先建立一个表空间YANG,接着建立一个YANG用户,最后建立一张USERS表。

 1 sys用户以Sysdba登录创建表空间YANG:
 2 create tablespace YANG
 3 datafile 'D:\app\Administrator\product\11.1.0\db_1\YANG.dbf' size 400M
 4 extent management local uniform size 512K;
 5 以system用户Normal登录,创建用户YANG:
 6 -- Create the user 
 7 create user YANG
 8   default tablespace YANG
 9   temporary tablespace TEMP
10   profile DEFAULT
11   password expire;
12 -- Grant/Revoke role privileges 
13 grant connect to YANG with admin option;
14 grant resource to YANG with admin option;
15 -- Grant/Revoke system privileges 
16 grant unlimited tablespace to YANG with admin option;
17 以YANG登录,创建表Users。
18 -- Create table
19 create table USERS
20 (
21   GID       NUMBER not null,
22   GUSERNAME NVARCHAR2(30) not null,
23   GPASSWORD NVARCHAR2(30) not null
24 )
25 tablespace YANG
26   pctfree 10
27   initrans 1
28   maxtrans 255
29   storage
30   (
31     initial 512K
32     next 512K
33     minextents 1
34     maxextents unlimited
35     pctincrease 0
36   );
37 -- Create/Recreate primary, unique and foreign key constraints 
38 alter table USERS
39   add constraint PRIMARYKEY primary key (GID)
40   using index 
41   tablespace YANG
42   pctfree 10
43   initrans 2
44   maxtrans 255
45   storage
46   (
47     initial 512K
48     next 512K
49     minextents 1
50     maxextents unlimited
51     pctincrease 0
52   );

 这里绘了一个用户权限管理的E-R图,不知道是否合理。

posted @ 2012-05-09 16:01  太一吾鱼水  阅读(344)  评论(0编辑  收藏  举报