sql随笔

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');
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值