1因各种各样的原因,事隔有点久,但愿总结顺利,总结分几块,如果各位有好的见议,请向我提出来,在此谢过!
2下面对Oracle常用的Sql语句进行总结:
--1表空间的创建与删除
--2表的创建与删除
--3表的增加,删除,修改
--4格式化时间等
--5这个记不清楚了,在plsql中sql.window中会报没有值插入,在Command.window中执行show off就可以在这个窗口中执行插入
--6表与表之间的联合查询
--7索引的增加与删除
--8外键,主键
--9视图焦点实习的时候没有用到,不过曾经好像在哪里用过,在这做个总结
--10以上所做的在plsql一大部分是可以在界面上实现的,不过还是要记得的,万一公司只能允许你写sql也不至于什么都不会。
--sql语句规范写法
--删除分类表
drop table sshe.HYL_BOOK_CLASS
--创建分类表
create table sshe.HYL_BOOK_CLASS
(
ID NUMBER(10) not null,
NAME VARCHAR2(50) not null,
DESCRIPTION VARCHAR2(200) not null
);
--Add comments to the table
comment on table sshe.HYL_BOOK_CLASS
is '图书分类';
comment on table sshe.HYL_BOOK_CLASS.ID
is '图书分类id';
comment on table sshe.HYL_BOOK_CLASS.NAME
is '图书分类描述';
comment on table sshe.HYL_BOOK_CLASS.DESCRIPTION
is '图书分类描述';
--Create/Recreate primary,unique and foreign key constraints(ken'streint 强制,限制,约束 )
alter table sshe.HYL_BOOK_CLASS
add constraint PK_HYL_BOOK_CLASS primary key (ID);
--创建索引
create index IDX_HYL_BOOK_CLASS_01 on sshe.HYL_BOOK_CLASS(DESCRIPTION);
alter table sshe.HYL_BOOK_CLASS
add constraint IDX_HYL_BOOK_CLASS_02 unique(NAME);
--主键序例化
create sequence S_HYL_BOOK_CLASS_01 on sshe.HYL_CLASS
minvalue 0 maxvalue 9999
start with 0 increment by 1
cache 20;
--简单增删改查
select * from sshe.HYL_BOOK_CLASS hbc where hbc.id=0;
insert into sshe.HYL_BOOK_CLASS values(1,'文学','文学是什么东西??');
update sshe.HYL_BOOK_CLASS hbc set hbc.name='理科' where hbc.id=0;
delete from sshe.HYL_BOOK_CLASS hbc where hbc.id=0;
今天就写到这!