手记

Oracle创建用户和表空间


  1. 在system下创建表空间:

    create tablespace CASETABLE
    datafile 'D:\app\CASETABLE.dbf' size 1024M --存储地址 初始大小1G
    autoextend on next 1024M maxsize unlimited   --每次扩展1G,无限制扩展
    EXTENT MANAGEMENT local  autoallocate
    segment space management auto;

  2. 在system下创建用户

    -- 创建用户
      create user ONECASE
      default tablespace CASETABLE
      temporary tablespace TEMP
      IDENTIFIED BY 123
      profile DEFAULT;

    -- 给用户授权
    -- Grant/Revoke role privileges
      grant connect to ONECASE;
      grant dba to ONECASE;
    -- Grant/Revoke system privileges
       grant create database link to ONECASE;
       grant unlimited tablespace to ONECASE;

  3. 在ONECASE用户下创建用户信息表

    -- Create table
    create table case_user
    (
      username VARCHAR2(32) not null,
      password  VARCHAR2(32) not null
    )
    tablespace CASETABLE
      pctfree 10
      initrans 1
      maxtrans 255
      storage
      (
        initial 64
        next 1
        minextents 1
        maxextents unlimited
      );
    -- Add comments to the table
    comment on table case_user
      is '用户登入信息表';
    -- Add comments to the columns
    comment on column case_user.username
      is '用户名';
    comment on column case_user.password
      is '密码';
    -- Create/Recreate primary, unique and foreign key constraints
    alter table case_user
      add constraint PK_LAS_CAMERABARCODE primary key (username)
      using index
      tablespace CASETABLE
      pctfree 10
      initrans 2
      maxtrans 255
      storage
      (
        initial 64K
        next 1M
        minextents 1
        maxextents unlimited
      );

0人推荐
随时随地看视频
慕课网APP