>添加数据
insert into 表名 (字段1) values(值1)
insert into stuinfo (stuname,stuno,stuage) values (''张三'',''s25010'',''22'')
>更新数据
update 表名 set 字段1=值1,………,where (条件)
update stuinfo set stuage = 25 where stuname = ''张三''
>查询数据
select 字段1,字段2,………,from 表名 where 条件 order by 字段名
select stuname,stuno from stuinfo where stuage < 25 order by stuno
>删除数据
delete from 表名 where 条件
delete from stuinfo where stuage < 20
………………………………………………………………………………………………………………………………
>创造数据库
create database studb
on primary
(
name = ''studb_data'',-----主数据文件的逻辑名
filename = ''D:\project\studb_data.mdf'',-----主数据文件的物理名
size = 5mb,-----主数据文件的初始大小
maxsize = 100mb,-----主数据文件增长的最大值
filegrowth = 15%-----主数据文件的增长率
)
log on
(
name = ''studb_log'',
filename = ''D:\project\studb_log.ldf'',
size = 5mb,
filegrowth = 1mb
)
go
………………………………………………………………………………………………………………………………
>创建多个数据文件和多个日志文件
create database employees
on primary
(
name = ''employee1'',
filename = ''D:\project\employee1_data.mdf'',
size = 5mb,
filegrowth = 10%
),
(
name = ''employee2'',
filename = ''D:\project\employee2_data.ndf''
size = 20mb,
maxsize = 10%,
filegrowth = 1
)
log on
(
name = ''employeelog1'',
filename = ''D:\project\employeelog1_log.ldf'',
size = 10mb,
filegrowth = 1
)
(
name = ''employeelog2'',
filename = ''D:\project\employeelog2_log.ldf'',
size = 10mb,
maxsize = 50mb,
filegrowth = 1
)
go
………………………………………………………………………………………………………………………………
>删除数据库
drop database 数据库名
drop database studb
use master-----以便访问SYSDATABASES表
go
if exists (select * from sysdatabases where name = ''studb'')
drop database studb
create database studb
on primary
(
………略………
)
log on
(
………略………
)
go
………………………………………………………………………………………………………………………………
>创建表
create table 表名
(
字段1 数据类型 列的特征
字段2 数据类型 列的特征
………
)
use studb
go
create table stuinfo
(
stuname varchar(20) not null,
stuno char(6) not null,
stuage int not null,
stuid numeric(18,0),-----身份证号,numeric(18,0)代表18位数字