zoukankan      html  css  js  c++  java
  • Oracle-基本SQL语句

    --添加一个表
    create table TestUser
    (
         id int primary key ,
         name varchar(20) ,
         address varchar(20) 
    )
    /*
     *设置序列号(标识列)
     */
    --第一步:创建SEQUENCE   
    create   sequence   s_country_id   increment   by   1   start   with   1   maxvalue   999999999;   
    --第二步:创建一个基于该表的before   insert   触发器,在触发器中使用该SEQUENCE   
    create   or   replace   trigger   bef_ins_t_country_define   
    before   insert   on   t_country_define   
    referencing   old   as   old   new   as   new   for   each   row   
    begin   
    select   s_country_id.nextval   into   :new.country_id   from   dual;   
    end;   
      
    --第二步也可以不做   
    --插入数据的语句这样写insert into   tb...  values(s_country_id.nextval,...);   
    
    --查所有
    select * from TestUser;
    --添加一条记录(根据创建的sequence来添加id)
    insert into TestUser (id,name,address) values (s_country_id.nextval,'李四','bbb');
    --根据条件删除记录
    delete TestUser where id=2
    --修改记录
    update TestUser set name='小明' where id=1 
    --删除表
    drop table TestUser;
    --删除表中记录时释放表空间(仅清空记录)
    truncate table TestUser;
    --为用户授权
    grant select any table to likeyi 
  • 相关阅读:
    python django day 1
    C# 日常
    C# NPOI使用
    SharpZipLib 压缩ZIP导出
    JSON劫持
    跨站请求伪造CSRF或XSRF
    跨站脚本XSS安全
    会话窃取
    Cookie
    Promise -ES6
  • 原文地址:https://www.cnblogs.com/xcxcxcxc/p/5541226.html
Copyright © 2011-2022 走看看