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 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值