文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>T-SQL学习第二天

T-SQL学习第二天

时间:2011-03-31  来源:混 混

--创建数据库
CREATE database mydbtest
on
(name
='mydbtest_Data',
filename
='C:\mydbtest_Data.MDF',
size
=1,
maxsize
=3,
filegrowth
=10%)
Log on
(
name
='mydbtest_Log',
filename
='C:\mydbtest_Log.LDF',
size
=1,
maxsize
=5,
filegrowth
=10%
)
GO
--创建表
create table UserManager
(
UserID
int IDENTITY(1,1) Not NUll PRIMARY KEY,--添加自动增量和主键
UserName char(20)
)
create table message
(
ProductName
char(30),
ProductInfo
char(50),
)

--修改表
--添加列
alter table message
add ProductID int
--修改表结构
alter table message
add constraint px_message
primary key clustered
(ProductID)
go
--删除列
alter table message
drop column ProductInfo
--删除表
drop table message
--向表中插入数据
insert into message(ProductName,ProductID)values('test',008)
--更新数据
update message set ProductName='guest' where ProductID=008
select * from message
--基本查询
use Northwind
go
select top 5 * from orders--查询前五行
select top 5 percent * from orders--查询5%
select distinct EmployeeID from orders--查询不重复
select * into number from orders where employeeID=5--into把查询结果生成一个新表

相关阅读 更多 +
排行榜 更多 +
幸存者的命运

幸存者的命运

飞行射击 下载
精英战区3d

精英战区3d

飞行射击 下载
货运猎人

货运猎人

飞行射击 下载