zoukankan      html  css  js  c++  java
  • Oracle中创建表,创建序列,创建自增字段,添加注释, 添加记录,添加触发器,提交

    --修改用户的密码

    select * from dba_users where username='TAOKAUSER';

    alter user TAOKAUSER identified by sasa;

    --授权
    grant all on dcs.dcs_category to bafapps;--  dcs.dcs_category(用户名.表名)  bafapps接收权限的用户名
    grant all on dcs.dcs_category_tl to bafapps;

    --创建同义词
    create synonym dcs_category for dcs.dcs_category;
    create synonym dcs_category_tl for dcs.dcs_category_tl;

    --创建表空间

    CREATE TABLESPACE TaoKa DATAFILE
      'D:\oracle\product\10.2.0\oradata\orcl\TaoKa' SIZE 1M AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED
    LOGGING
    ONLINE
    PERMANENT
    EXTENT MANAGEMENT LOCAL AUTOALLOCATE
    BLOCKSIZE 8K
    SEGMENT SPACE MANAGEMENT MANUAL;

    --创建用户
    CREATE USER TaoKaUser
      IDENTIFIED BY VALUES '35CC57B23E8092CD'
      DEFAULT TABLESPACE TaoKa
      TEMPORARY TABLESPACE TEMP
      PROFILE DEFAULT
      ACCOUNT UNLOCK;
      -- 3 Roles for TaoKa
      GRANT CONNECT TO TaoKaUser WITH ADMIN OPTION;
      GRANT DBA TO TaoKaUser WITH ADMIN OPTION;
      GRANT RESOURCE TO TaoKaUser WITH ADMIN OPTION;
      ALTER USER TaoKaUser DEFAULT ROLE ALL;
      -- 5 System Privileges for TaoKa
      GRANT INSERT ANY TABLE TO TaoKaUser WITH ADMIN OPTION;
      GRANT SELECT ANY SEQUENCE TO TaoKaUser;
      GRANT SELECT ANY TABLE TO TaoKaUser WITH ADMIN OPTION;
      GRANT UNLIMITED TABLESPACE TO TaoKaUser WITH ADMIN OPTION;
      GRANT UPDATE ANY TABLE TO TaoKaUser WITH ADMIN OPTION;
      -- 2 Tablespace Quotas for TaoKa
      ALTER USER TaoKaUser QUOTA UNLIMITED ON TaoKa;
      ALTER USER TaoKaUser QUOTA UNLIMITED ON TaoKa;

    // 创建一个序列
    CREATE SEQUENCE Car_GUID increment by 1;

    // 创建一个表
    CREATE TABLE Car
    (
     GUID NUMBER NOT NULL PRIMARY KEY,
     PhoneId Char(11) NOT NULL,
     UserName VarChar(20) NOT NULL
    );

    // 添加注释
    comment on table car is '定位信息用户表';
    Comment on column car.guid is '自增字段';
    Comment on column Car.PhoneId is '电话唯一标识';
    Comment on column Car.UserName is '用户名称';

    // 添加一条记录
    INSERT INTO Car(GUID, PhoneId, UserName) Values(CAR_GUID.nextval, '13589256783', '张三');

    // 提交
    commit;

    // 触发器
    create or replace trigger Trigger_Car_GUID_Insert 
    before insert on Car
    for each row
    begin
     select CARGUIDSEQ.nextval into  :new.GUID from sys.dual;
    end;

  • 相关阅读:
    雅虎网站页面性能优化的34条黄金守则
    borderimage
    jQuery实现滚动加载图片效果
    mysql数据库中创建与删除数据表
    (10)一步一步开发一个简单CAD之捕捉
    apach启动失败的原因
    (12)一步一步开发一个简单CAD之观察者模式
    简单基于OPENGL的三维CAD框架(1)照相机类
    简单基于OPENGL的三维CAD框架(1)COpenGLDC
    (13)一步一步开发一个简单CAD之像皮筋类
  • 原文地址:https://www.cnblogs.com/huanghai223/p/1863930.html
Copyright © 2011-2022 走看看