컬렉션 조회
-- , , ,
-- " "
-- :Sno, char(9)--> 9 ;
-- :Sname, varchar2(8)--> 2,3,4 , ;
-- :Sage, smallint-->smallint , ,-32,768-->32,767;
-- :Ssex, char(2)--> ,' ' ' ', 2 ;
-- :Sdept, varchar2(4)--> , 4 ;
-- ;
create table Student
(
Sno char(9) primary key,
Sname varchar2(8),
Ssex char(2) not null,
Sage smallint not null,
Sdept varchar2(4) not null
);
-- " "
-- :Cno, char--> 4 ;
-- :Cname, varchar2--> , 10 , 20 ;
-- :Cpno, char--> ;
-- :Ccredit, smallint--> ;
-- " " Cno;
-- " " Cpno; Cpno Cno;
create table Course
(
Cno char(4) primary key,
Cname varchar2(20) not null,
Cpno char(4),
Ccredit smallint not null,
foreign key(Cpno) references Course(Cno)
);
-- " "
-- Sno, char(9)--> 9 ;
-- Cno, char(4)--> 4 ;
-- Grade, smallint--> 0->100 ;
-- :Cno Sno ;
-- : Sno Student Sno; Cno Courses Cno;
create table SC
(
Sno char(9),
Cno char(4),
Grade smallint,
primary key(Sno,Cno),
foreign key(Sno) references Student(Sno),
foreign key(Cno) references Course(Cno)
);
-- ,
-- value=ZHS16GBK, 2 , 2 ;
-- value=AL32UTF8, 3 , 3 ;
select * from v$nls_parameters t where t.PARAMETER='NLS_CHARACTERSET';
alter user scott account unlock;
alter user sys account unlock;
alteruseruser_name account unlock identifiedby new_password;
-- value = ZHS16GBK, .
--
insert into Student values('201215121',' ',' ',20,'CS');
insert into Student values('201215122',' ',' ',19,'CS');
insert into Student values('201215123',' ',' ',18,'MA');
insert into Student values('201215125',' ',' ',19,'IS');
--
insert into Student values('201215121',' ',' ',20,'CS');
insert into Student values('201215122',' ',' ',19,'CS');
--
insert into Student values(null,' ',' ',19,'CS');
insert into Student values(null,' ',' ',20,'IS');
--
insert into Student values('201215126',' ',' ',null,'IS');
insert into Student values('201215126',' ',null,30,'IS');
--
select * from Student;
--
drop table Student;
--
-- , --> Cpno ;
-- , --> , , ;
insert into Course values('2',' ',null,2);
insert into Course values('6',' ',null,2);
insert into Course values('4',' ','6',3);
insert into Course values('7','PASCAl ','6',4);
insert into Course values('5',' ','7',4);
insert into Course values('1',' ','5',4);
insert into Course values('3',' ','1',4);
--
insert into Course values('1',' ','5',5);
insert into Course values('3',' ','1',4);
--
insert into Course values(null,' ','5',4);
insert into Course values(null,' ','7',4);
--
insert into Course values('8',' ','20',4);
insert into Course values('9',' ','11',4);
--
insert into Course values('10',' ','7',null);
insert into Course values('13',' ','6',null);
-- ,
insert into Course values('2',' ',null,2);
insert into Course values('6',' ',null,2);
--
select * from Course;
--
drop table Course;
--
-- , , ;
-- , ;
-- ,
insert into SC values('201215121','1',92);
insert into SC values('201215121','2',85);
insert into SC values('201215121','3',88);
insert into SC values('201215122','2',90);
insert into SC values('201215122','3',80);
--insert into SC values('201215122','1',90);
-- ,
insert into SC values('201215122','9',100);
insert into SC values('201400644','1',70);
-- , ,
insert into SC values('201215122','3',90);
insert into SC values('201215121','1',92);
-- ,
insert into SC values('201215122',null,90);
insert into SC values(null,'2',70);
--
select * from SC;
--
drop table SC;
--select
-- , ,
-- union, intersect, except
-- 19
-- 19
select *
from Student
where Sdept='CS'
union
select *
from Student
where Sage<=19;
-- union ,
-- , ,
-- union all
-- ,
--
select *
from Student
where Sdept='CS'
union all
select *
from Student
where Sage>=19;
-- or
-- 19
select *
from Student
where Sdept='CS' or Sage<=19;
-- 1 2
-- 2
select *
from SC
where Cno='1'
union
select *
from SC
where Cno='2';
-- , union all
select *
from SC
where Cno='1'
union all
select *
from SC
where Cno='2';
--
--
select *
from SC
where Cno='1' or Cno='2';
-- 19
select *
from Student
where Sdept='CS'
intersect
select *
from Student
where Sage<=19;
-- , and
-- and
select *
from Student
where Sdept='CS' and Sage<=19;
-- 1 2 .
-- , 2
-- intersect
select Sno
from SC
where Cno='1'
intersect
select Sno
from SC
where Cno='2';
select *
from SC
where Cno='1'
intersect
select *
from SC
where Cno='2';
-- ?
--
-- 1 , 2 ,
-- : 2
-- 2
select Sno
from SC
where Cno='2';
-- 2
select Sno
from SC
where (Sno='201215121' or Sno='201215122') and Cno='2'
-- in
select Sno
from SC
where Sno in('201215121' ,'201215122') and Cno='2';
-- : 1 2
select Sno
from SC
where Cno='1';
-- , 1
select Sno
from SC
where (Sno='201215121' or Sno='201215122') and Cno='1';
-- in
select Sno
from SC
where Sno in('201215121' ,'201215122') and Cno='1';
-- 19
select *
from Student
where Sdept='CS'
except
select *
from Student
where Sage<=19;
-- ?ORA-00933: SQL
-- 19
select *
from Student
where Sdept='CS' and Sage>19;
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Oracle 생성 향후 3일간의 전체 시점 (단계 상세)수요: X 좌표축 시간은 모두 정시 시간으로 앞으로 3일 동안의 예측을 보여준다(x 축은 앞으로 3일 동안의 정시 시간을 보여준다), 3시간마다 한 눈금, 가로 좌표는 모두 24개의 눈금을 보여준다 1단계: 현재 시...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.