数据库创建:
CREATE DATABASE student
ON PRIMARY(
NAME='student',
FILENAME='E:\student.mdf',
SIZE=5MB,
MAXSIZE=30MB,
FILEGROWTH=1MB)
LOG ON
(NAME='student_log',
FILENAME='E:\student_log.ldf',
SIZE=2MB,
MAXSIZE=10MB,
FILEGROWTH=5%)
COLLATE Chinese_PRC_CI_AS
------------------------------------------------------------
CREATE DATABASE wsqdata
on primary
(
name=wsqdata,--逻辑名
filename='e:\_wsqdata.mdf',--物理名
size=3,
maxsize=50,
filegrowth=10%
)
log on
(
name=wsqlog,
filename='e:\_wsqlog.ldf',
size=3,
maxsize=50,
filegrowth=3
)
创建表
use wsqdata
go
create table score1
(
name nchar(10) primary key not null,
id nchar(10)not null,
score int not null
)
插入数据
use wsqdata
go
insert into score
values('章敏','42','100','男')
新增列
use wsqdata
go
alter table score
add sex nchar(2)
删除数据
use wsqdata
go
delete from score
where sex='男'
go
创建联合主键
use wsqdata
go
create table score2
(
name nchar(10) not null,
id nchar(10)not null,
score int not null
primary key(name,id)
)
CREATE DATABASE student
ON PRIMARY(
NAME='student',
FILENAME='E:\student.mdf',
SIZE=5MB,
MAXSIZE=30MB,
FILEGROWTH=1MB)
LOG ON
(NAME='student_log',
FILENAME='E:\student_log.ldf',
SIZE=2MB,
MAXSIZE=10MB,
FILEGROWTH=5%)
COLLATE Chinese_PRC_CI_AS
------------------------------------------------------------
CREATE DATABASE wsqdata
on primary
(
name=wsqdata,--逻辑名
filename='e:\_wsqdata.mdf',--物理名
size=3,
maxsize=50,
filegrowth=10%
)
log on
(
name=wsqlog,
filename='e:\_wsqlog.ldf',
size=3,
maxsize=50,
filegrowth=3
)
创建表
use wsqdata
go
create table score1
(
name nchar(10) primary key not null,
id nchar(10)not null,
score int not null
)
插入数据
use wsqdata
go
insert into score
values('章敏','42','100','男')
新增列
use wsqdata
go
alter table score
add sex nchar(2)
删除数据
use wsqdata
go
delete from score
where sex='男'
go
创建联合主键
use wsqdata
go
create table score2
(
name nchar(10) not null,
id nchar(10)not null,
score int not null
primary key(name,id)
)