SQL Server表的增删改查、修改列名和多表关联

SQL Server中表的增删改查、修改列名以及三表关联

向表中添加数据

insert into Novel(Novel_Name,Author,Intro,Cover,Hits,Comments,InputDate,isProduct,ProductDate, isDelete,DeleteDate,isDown,DownDate) values ('西游记','吴','取经','唐僧',0,0,getdate(),1,getdate(),1,getdate(),0,getdate()) insert into Novel(Novel_Name,Author,Intro,Cover,Hits,Comments,InputDate,isProduct,ProductDate, isDelete,DeleteDate,isDown,DownDate) values ('水浒传','施耐庵','起义','宋江',0,0,getdate(),1,getdate(),1,getdate(),0,getdate()) 
insert into Novel(Novel_Name,Author,Intro,Cover,Hits,Comments,InputDate,isProduct,ProductDate,
isDelete,DeleteDate,isDown,DownDate) values ('诛仙','未知','','',0,0,getdate(),1,getdate(),1,getdate(),0,getdate())
insert into Novel(Novel_Name,Author,Intro,Cover,Hits,Comments,InputDate,isProduct,ProductDate,
isDelete,DeleteDate,isDown,DownDate) values ('天龙八部','金庸','侠义','乔峰',0,0,getdate(),1,getdate(),1,getdate(),0,getdate())

删除表中数据

delete from Novel where Novel_Name = '水浒传'
delete from Novel where Novel_Name = '西游记'

查询表中数据

select * from Novel order by Novel_ID desc --查询表并按倒序排序,正序是order by asc
select *from Novel_Class

修改列名

alter table Novel_class add reorder int default(0) not null--alter table 名 add  列名 类型 默认值 

三表查询语句

select a.* b.*,c.* from 
Novel a inner join Ass c
 on a.Novel_ID=c.Novel_ID 
 inner join inner join Novel_Class b
 on b.Class_ID=c.Class_ID
 where Class_Name='武侠'


你可能感兴趣的:(SQL Server表的增删改查、修改列名和多表关联)