sql server入门语句

2014-11-24 12:18:14 · 作者: · 浏览: 0

sql server入门语句
create database firstTestDB
go
/*使用 数据库*/
use firstTestDB
www.2cto.com
go
--创建第一个表
create table firstTable(id int not null,name varchar(50) not null)
go
--创建第二个表
create table secondTable(id int not null primary key,name varchar(50))
go
--创建第三个表
create table thirdTable(id int primary key not null)
go
--插入数据进入第一个表中
insert into firstTable values(1,'zhao')
go
insert into firstTable values(2,'wang')
go www.2cto.com
--插入数据到第二个表中
insert into secondTable(id,name) values(43,'heng')
go
--查询第一个表中的数据
select * from firstTable
go
--约束第一个表中的id为主键
alter table firstTable add constraint pk_id primary key(id)
go
作者 zhaohengyong