zoukankan      html  css  js  c++  java
  • 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图,不知道是否合理。

    文章未经说明均属原创,学习笔记可能有大段的引用,一般会注明参考文献。 欢迎大家留言交流,转载请注明出处。
  • 相关阅读:
    电容的串联和并联的性质
    start.sh
    shell 得到当前目录路径
    Java程序远程无法执行nohup命令
    mysql windows 安装5.7
    电阻并联的性质
    电阻串联的性质
    webjars
    邮箱设置
    万用表使用注意事项
  • 原文地址:https://www.cnblogs.com/yhlx125/p/2491941.html
Copyright © 2011-2022 走看看