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