sql server入门

create database firstTestDB
go数据库

/*使用数据库*/
use firstTestDBtable

go
--建立第一个表
create table firstTable(id int not null,name varchar(50) not null)select

go
--建立第二个表
create table secondTable(id int not null primary key,name varchar(50))
go
--建立第三个表
create table thirdTable(id int primary key not null)
goim

--插入数据进入第一个表中
insert into firstTable values(1,'zhao')
go
insert into firstTable values(2,'wang')
go
--插入数据到第二个表中
insert into secondTable(id,name) values(43,'heng')
go数据

--查询第一个表中的数据
select * from firstTable
go查询

--约束第一个表中的id为主键
alter table firstTable add constraint pk_id primary key(id)
gotab

相关文章
相关标签/搜索