首页 > 数据库技术 > 详细

SQL语句创建表和数据库

时间:2014-12-18 10:15:41      阅读:249      评论:0      收藏:0      [点我收藏+]

创建数据库的SQL语句:

 1 use practice
 2 go 
 3 if exists (select * from sysobjects where name=practice)
 4 drop table Store_Information
 5 create table Store_Information
 6 (
 7   storeID int identity(1,1) primary key,--列属性"identity(起始值,递增量)"
 8   store_Name varchar not null,
 9   store_Money decimal null,
10   store_Date date not null,
11 )

 

删除数据库,SQL Server将数据库的清单存放在master系统数据库的sysdatabases表中,只需要查看该表是否存在于该数据库中就可以

了,语句如下:

1 use master -- 设置当前数据库为master,以便访问sysdatabases表
2 go 
3 if exists (select * from sysdatabases where name=practice)
4 drop database practice

创建表的SQL语句如下:

 

 1 use practice
 2 go 
 3 if exists (select * from sysobjects where name=practice)
 4 drop table Store_Information
 5 create table Store_Information
 6 (
 7   storeID int identity(1,1) primary key,--列属性"identity(起始值,递增量)"
 8   store_Name varchar not null,
 9   store_Money decimal null,
10   store_Date date not null,
11 )

 

SQL语句创建表和数据库

原文:http://www.cnblogs.com/zhaomengmeng/p/4171040.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!