sql server 2008学习笔记(一)

--创建数据库--
create database db01
go --使语句继续执行

--使用db01--
use db01
go

--创建表worker,1个主键--
create table worker
(
W_ID int primary key,
W_name varchar(10) not null,
W_age int not null,
W_sex varchar(2) check(W_sex in('男','女')) not null,
W_job varchar(10) not null
)

--创建表salary,2(多)个主键(主码)--
create table salary
(
S_ID int,
S_date date,
S_totalsalary decimal(10,1),
S_actualsalary decimal(10,1),
primary key(S_ID,S_date)
)

--删除数据库--
drop database db02

创建索引的一般语句格式

--unique 代表唯一索引
--clustered 聚集索引
create [unique] [clustered] index<索引名>
on<表名> (<列名>[<次序>][,<列名2>[<次序>]])

例:

use db01
create unique clustered index index_id
on salary(S_ID desc,S_date desc)
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值