您的位置:首页 > 数据库 > Oracle

Oracle 基本语句语法

2009-08-20 22:01 281 查看
Oracle 语法学习
1. sequence 序列学习
create sequence seq_test3
increment by 1
minvalue 1
maxvalue 999999999999999
start with 1
--cache 缓冲值,nextvalue 值时 首先去cache 中获取值,如果cache值用完系统会自动再再创建对应 cache 设定数量个序列值,
--提高序列获取速度,使用cache 或许跳号 , 为避免此现象 可以用 nocache
cache 10
--对sequence 基本操作
---删除序列操作
drop sequence seq_test3
---查询sequence 初始值 刚刚建的序列必须用nextval 来获取一个初始值
select seq_test3.nextval from dual
---获取当前序列值
select seq_test3.currval from dual
-- 清除缓存中序列值
alter system flush shared_pool
---清除缓存中序列值后,下一个值将变成 cache 当前值 + increment by 值
select seq_test3.currval from dual
---
select seq_test3.nextval from dual
---修改sequence 自动增长 参数
alter sequence seq_test3
increment by 10;
---修改 sequence 最小值
alter sequence seq_test3
minvalue 3
-- 修改 sequence 最大值
alter sequence seq_test3
maxvalue 8888
---修改 缓冲 cache 值
alter sequence seq_test3
cache 88
--- 修改 start with 值 不能直接修改 起始值 只用通过 drop 再re—create 才能改变
alter sequence seq_test3
start with 3
---以上方法报错 ,以下为正确方法
drop sequence seq_test3

create sequence seq_test3
increment by 1
minvalue 1
maxvalue 999999999999999
start with 88

2. 基本sql 语句
---创建表语句
create table creat_test
(
table_name varchar2(20),
create_date date

)
--插入表数据语句
insert into creat_test(table_name,create_date) values('table1',to_date('2009-08-06','YYYY-MM-DD'));
commit

insert into creat_test(table_name,create_date) values('table2',to_date('2009-8-9','YYYY-MM-DD'))
----查询表数据语句
select t.* from creat_test t
-- 删除数据语句
delete creat_test ;
commit;
insert into creat_test(table_name,create_date) values(seq_test.nextval,to_date('2009-8-8','YYYY-MM-DD'));
COMMIT;
---更新表语句
update creat_test t set t.create_date = to_date('2009-9-8','YYYY-MM-DD') where t.table_name = '1';
commit
----级联删除语句把发放单【200905270138】中器具从入库中删除掉,删除发放单中器具关联语句。
---级联删除语句
delete t_em_qj t1
where
exists (select 'x' from t_em_ffd_qj f where f.bh_fk = t1.bh and f.dh_fk = '200905270138');
delete t_em_ffd_qj t where t.dh_fk = '200905270138';
commit;
select t.*,t.rowid from t_em_ffd_qj t where t.dh_fk = '200905270138'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: