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, &#
【SQLServer高级查询与T-SQL编程】
最新推荐文章于 2024-09-15 17:50:36 发布
本文档展示了在SQL Server中创建和管理数据库、表的操作,包括插入数据、查询作者和书籍信息。还涉及到了使用别名、子查询、视图、索引、存储过程等高级查询和编程技巧。最后,通过一个存储过程演示了如何根据作者姓名删除作者及其关联书籍信息。
摘要由CSDN通过智能技术生成