AnnyQin老師帶來的SQL語句練習(xí)題,歡迎大家來練習(xí)!
第二章練習(xí)題:
1、創(chuàng)建一個名為OracleTest的表空間,并將改表空間設(shè)置為system用戶的默認(rèn)表空間
2、刪除oracletest表空間的語句什么?(注意,在刪除該表空間后,還要為system用戶指定其他的默認(rèn)表空間)
第三章練習(xí)題:
1、創(chuàng)建名為test的表,該表用于存放某公司面試考試題庫,包括題目編號(id)、題目 (topic)、答案(answer)、題型(types)、備注(remark)5個字段,字段類型自定義。
2、給表中的題目字段的數(shù)據(jù)類型更改成varchar2(200)
3、將題型字段的名字更改成new_type
4、刪除表中的答案字段
第四章練習(xí)題:
1、向第2章中創(chuàng)建的test表中全部字段中任意添加2條記錄
2、向test表中的編號、題目、答案這3個字段中任意添加1條記錄
3、將編號是10001的題目中,備注更改成“2014年新題型”
4、將題型中“組織管理”類的題目中,題目前面都加上“組織管理”,并且在備注中更改成“重點(diǎn)”
5、 將所有“組織管理”類的題目全部刪除
第五章練習(xí)題:
test表,包括題目編號(id)、題目 (topic)、答案(answer)、題型(types)、備注(remark)5個字段,字段類型自定義。
1、 在創(chuàng)建test表中為題目編號字段設(shè)置主鍵約束、題目字段設(shè)置唯一約束
2、在修改test表時,為題型字段加上非空約束
3、創(chuàng)建一個題型信息表(typeinfo),字段包括題型編號(typeid)、題型(typename)
并將題型編號字段設(shè)置主鍵約束,題型設(shè)置非空約束、唯一約束
4、修改test表,為題型字段添加與題型信息表的題型編號字段的外鍵約束
5、將test表中的外鍵約束刪除
第六章練習(xí)題:
1、查詢test表,顯示所有組織管理類的題目
2、查詢test表,顯示所有是組織管理類題目并且題目中含有“組織”的題目和答案
3、查詢test表,顯示題型是組織管理類或綜合分析類的題目,并且備注中含有“2014新題型”的所有題目和答案
2015-07-12
--第二章練習(xí)題:
--1
create tablespace OracleTest
datafile 'oracletest.abf' size 10m;
alter user system
default tablespace oracletest;
--2
drop tablespace OracleTest;
alter user system
default tablespace system;
--第三章練習(xí)題:
--1
create table test(
id number(6,0),
topic nvarchar2(50),
answer varchar2(100),
types varchar2(50),
remark varchar2(100));
--2
alter table test?
modify topic varchar2(200);
--3
alter table test
rename column types
to new_type;
--4
alter table test
drop column answer;
--第四章練習(xí)題:
--1
insert into test#(id,topic,remark,new_type)
values('04','數(shù)學(xué)','選擇題','組織管理');
insert into test(id,topic,remark,new_type)
values('02','英語','計算題','困難');
--2
alter table test
add answer varchar2(200);
insert into test(id,topic,answer)
values('10001','JAVA','200');
--3
update test
set remark='2014年新題型'
where id='10001';
--4
update test
set remark='重點(diǎn)'
where new_type='組織管理';
--5
delete from test
where topic='組織管理';
--第五章練習(xí)題:
--1
create table test#(
id number(6,0)primary key,
topic varchar2(200) unique,
answer varchar(200),
types varchar(200),
remark varchar(100));
--2
alter table test?
modify types not null;
--3
create table typeinfo(
typeid varchar(100) primary key,
typename nvarchar2(100) unique not null);
--4
alter table test#
add constraint SYS_C005587 foreign key (types) references typeinfo(typeid);?
--5
alter table test#
drop constraint SYS_C005587;?
--第六章練習(xí)題:
--1
select topic ?from test
where types='組織管理';
--2
select topic,answer ?from test
where types='組織管理'and topic like '%組織%';
--3
select topic,answer ?from test
where types in('組織管理','綜合分析')and remark like
'%2014新題型%';?