create table student(
Sno char(9),
Sname char(20),
Sage int,
)
ALTER Table student ALTER Column Sno char(9) not NULL
alter table student add constraint pk_s primary key (Sno)
create table teacher(
Tno char(9) primary key,
Tname char(20),
Tage int,
)
create table scoure(
Sno CHAR(9),
Tno CHAR(9),
Cname CHAR(9),
Cno char(9) primary key(Sno,Tno),
foreign key(Sno) references student(Sno),
foreign key(Tno) references teacher(Tno),
)
/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP 1000 [id]
,[name]
,[url]
,[alexa]
,[country]
FROM [ChoseSC].[dbo].[websites]
SELECT name,country FROM websites;
select name,country from websites;
select * from websites;
/*投影π country(websites) */
select distinct country from websites;
select * from websites where country='CN';
select * from websites where id=1;
select * from websites where country='CN' and alexa>15;
SELECT * FROM Websites WHERE country='USA' OR country='CN';
select * from websites where alexa>15 and (country='CN' or country='USA');
/*升序排列*/
SELECT * FROM Websites ORDER BY alexa;
/*降序排列*/
select * from websites order by alexa desc;
SELECT * FROM Websites ORDER BY country,alexa;
insert into websites (name,url,alexa,country)
values ('百度','https://www.baidu.com/','4','CN');