如何在SQL Server2008中用代码建库建表
展开全部
CREATE DATABASE Sales
ON
( NAME = Sales_dat,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\saledat.mdf',
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = Sales_log,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\salelog.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB ) ;
GO
create table bas_role_tb (
id_role int identity,
role_code varchar(30) null,
role_name varchar(60) null,
del_flag tinyint null default 0,
oper_date datetime null default getdate(),
id_user int null,
remark varchar(600) null,
constraint bas_role_pk primary key (id_role)
)
go
展开全部
如下示例:
--检验用户角色表(UA_Role)是否存在,若已存在则删除
if exists(Select * From SysObjects Where Name = 'UA_Role')
Drop Table [UA_Role]
go
--创建用户角色表(UA_Role)
Create Table [UA_Role]
(
--主键列,角色组编码
[cGroup_Id] int IDENTITY(1,1) Not Null,
--角色组名称
[cGroup_Name] VarChar(40) Not Null,
--角色组说明
[cGroup_Des] VarChar(60) Null,
CONSTRAINT [PK_UA_Role] PRIMARY KEY NONCLUSTERED ([cGroup_Id] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
go
--检验用户角色表(UA_Role)是否存在,若已存在则删除
if exists(Select * From SysObjects Where Name = 'UA_Role')
Drop Table [UA_Role]
go
--创建用户角色表(UA_Role)
Create Table [UA_Role]
(
--主键列,角色组编码
[cGroup_Id] int IDENTITY(1,1) Not Null,
--角色组名称
[cGroup_Name] VarChar(40) Not Null,
--角色组说明
[cGroup_Des] VarChar(60) Null,
CONSTRAINT [PK_UA_Role] PRIMARY KEY NONCLUSTERED ([cGroup_Id] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
go
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询