【SQLServer高级查询与T-SQL编程】

本文档展示了在SQL Server中创建和管理数据库、表的操作,包括插入数据、查询作者和书籍信息。还涉及到了使用别名、子查询、视图、索引、存储过程等高级查询和编程技巧。最后,通过一个存储过程演示了如何根据作者姓名删除作者及其关联书籍信息。
摘要由CSDN通过智能技术生成

use master
go
if exists(select * from sys.databases where name='bookDB')
    drop database bookDB
go
create database bookDB
go
use bookDB
go
if exists(select * from sys.objects where name='tb_Author')
    drop table tb_Author
go
create table tb_Author
(
    did int identity(1,1) primary key,
    name nvarchar(20) not null,
    gender int check(gender =1 or gender=0),
    country nvarchar(20) default('中国')
)
go
if exists(select * from sys.objects where name='tb_book')
    drop table tb_book
go
create table tb_book
(
    mid int identity(1,1) primary key,
    title nvarchar(20) not null,
    did  int references tb_author(did),
    Publish date
)
go
insert tb_Author values('老舍', 1, '中国')
insert tb_Author values('冰心', 0, &#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值