drop table student
create table student(
id varchar2(10) primary key,
ename varchar2(20),
empno varchar2(5)
)
insert into student values(1,‘张三‘,‘1001‘);
insert into student values(2,‘李四‘,‘1002‘);
commit;
update student set ename=‘小小‘ where empno=‘1002‘;
select *from student;
--锁定整个表
select *from student for update;
--在一条语句已经处于锁定状态时,还继续执行nowait语句的话 那么就会抛出00054异常
select *from student for update nowait;
select *from student for update wait 5; --获取该数据,如果5秒后还未获取到,那么抛出异常
--显示事务、
drop table myemp;
create table myemp(
empno varchar2(10),
ename varchar2(10),
job varchar2(10),
birthday varchar2(10),
pay integer
)
select *from myemp;
insert into myemp values(1234,‘张三‘,‘程序员‘,sysdate,10000);
savepoint sp_a;--设置一个保存点
insert into myemp values(4567,‘李四‘,‘工程师‘,sysdate,20000);
savepoint sp_b;--设置一个保存点
commit;
delete from myemp;
rollback to sp_a;
rollback to sp_b;
create tablespace g_space01 datafile ‘F:\tablespace\gr1.dbf‘ size 5M;
create tablespace g_space02 datafile ‘F:\tablespace\gr2.dbf‘ size 5M;
create tablespace g_space03 datafile ‘F:\tablespace\gr3.dbf‘ size 5M;
create tablespace g_space04 datafile ‘F:\tablespace\gr4.dbf‘ size 5M;
drop table sales
create table sales(
product_id int,
sales_cost number(10)
)
partition by range( sales_cost)(
partition p1 values less than(100) tablespace g_space01,
partition p2 values less than(200) tablespace g_space02,
partition p3 values less than(300) tablespace g_space03,
partition p4 values less than(400) tablespace g_space04
)
select *from sales
--创建id 自增序列
create sequence seq_sales_product_id;
--插入海量数据
insert into sales seq_sales_product_id.nextval, DBMS_RANDOM.VALUE(0,299) from dual
connect by level <=4000000;
select *from sales;
select *from sales where sales_cost<100; --99990
select *from sales partition(p1);
原文:http://www.cnblogs.com/KOAN-lcd/p/6681180.html