use--引用数据库后面跟数据库名称
exists--存在,一般与if连用,用于判断是否是否存在某种数据
drop--删除,用与删除数据库,表,如:drop database 数据库名,drop table 表名
database--数据库
table--表
primary key--主键
identity--自增,如:identity(1,1),注:自增键只能与主键合用
not null--非空,此列不允许为空
int--数据类型,整数
varchar()--数据类型,文本
use master--引用系统数据库master
go
if exists(select * from sys.databases where name='qq')--判断是否存在数据库qq
drop database qq--如果存在数据库qq,则删除
go
create database qq --创建数据库qq
go
use qq--引用数据库qq
go
create table Student--创建表Student
(
id int primary key identity(1,1),--主键列,id自增
name varchar(10) not null,--姓名列,不可为空
sex varchar(2)--性别列
)
insert into Student values('小明','男')--为表Student添加一条数据
insert into Student values('小红','女')
delete from Student where id=1--删除表中id为1的数据
update Student set name='小张' where id=2--修改id为2的数据姓名为小张
select * from Student--查看表Student
喜欢的话支持一下我的淘宝店哈
https://shop595806403.taobao.com/?spm=a1z10.1-c.0.0.e3287e78NiSnyq