设为首页 加入收藏

TOP

利用T--SQL语言操作数据表
2014-11-24 07:22:42 来源: 作者: 【 】 浏览:0
Tags:利用 T--SQL 语言 操作 数据
利用T--SQL语言操作数据表
---检查 数据库是否存在
use master
go
if exists(select * from sysdatabases where name='studentdb')
drop database studentdb
----创建数据库
Create database studentdb
on primary (
name='sudent',
filename='d:\data\student.mdf',
size=10,
maxsize=50,
filegrowth=3
)
log on (
name='student-log',
filename='d:\data\student-log.ldf',
size=15,
filegrowth=15%
)
---创建第一张表
use studentdb
go
if exists (select * from sysobjects where name='t_student')
drop table t_student
create table t_student
(
sno char(3) not null,
sname char(20) null,
sdenger char(2) not null,
sbirth datetime null,
sclass varchar(20) not null
)
---创建第二张表
use studentdb
go
if exists (select * from sysobjects where name='t_course')
drop table t_course
create table t_course
(
cno char(3) not null,
cname char(20) null
)
--创建第三张表
use studentdb go
if exists (select * from sysobjects where name='t_score')
drop table t_score
create table t_score
(
sno char(3) not null,
cno char(3) not null,
score int not null
)
--修改列
alter table t_student
alter column sno char(12)
--增加列
alter table t_student
add sfavorate char(30)
--删除列
alter table t_student
drop column sfavorate
--查看表
sp_help t_student
--删除表
drop table t_student
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇sql server表的管理 下一篇SQL2000事务回滚问题

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Java 并发工具类:提 (2025-12-25 20:25:44)
·Java面试技巧:如何 (2025-12-25 20:25:41)
·Java并发编程中的线 (2025-12-25 20:25:38)
·C 语言 - cppreferen (2025-12-25 19:50:27)
·《C 语言入门教程》 (2025-12-25 19:50:23)