用sql2000查询分析器做一个数据库实例
- 提问者网友:战皆罪
- 2021-04-15 18:51
- 五星知识达人网友:迟山
- 2021-04-15 19:35
CREATE DATABASE Lottery
GO
CREATE TABLE [Lottery].[dbo].[KL10] (
[iYEAR] [smallint] NOT NULL ,
[iMonth] [smallint] NOT NULL ,
[iDay] [smallint] NOT NULL ,
[QiHao] [smallint] NOT NULL ,
[KaiJiang1] [smallint] NOT NULL ,
[KaiJiang2] [smallint] NOT NULL ,
[KaiJiang3] [smallint] NOT NULL ,
[KaiJiang4] [smallint] NOT NULL ,
[Kaijiang5] [smallint] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [Lottery].[dbo].[T_36S7_Open] (
[TID] [int] NOT NULL ,
[T1] [smallint] NOT NULL ,
[T2] [smallint] NOT NULL ,
[T3] [smallint] NOT NULL ,
[T4] [smallint] NOT NULL ,
[T5] [smallint] NOT NULL ,
[T6] [smallint] NOT NULL ,
[TN] [smallint] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[KL10] WITH NOCHECK ADD
CONSTRAINT [PK_KL10] PRIMARY KEY CLUSTERED
(
[iYEAR],
[iMonth],
[iDay],
[QiHao]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[T_36S7_Open] WITH NOCHECK ADD
CONSTRAINT [PK_T_36S7_Open] PRIMARY KEY CLUSTERED
(
[TID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[KL10] WITH NOCHECK ADD
CONSTRAINT [DF_KL10_iYEAR] DEFAULT (datepart(year,getdate())) FOR [iYEAR],
CONSTRAINT [DF_KL10_iMonth] DEFAULT (datepart(month,getdate())) FOR [iMonth],
CONSTRAINT [DF_KL10_iDay] DEFAULT (datepart(day,getdate())) FOR [iDay],
CONSTRAINT [DF_KL10_QiHao] DEFAULT (0) FOR [QiHao],
CONSTRAINT [DF_KL10_KaiJiang1] DEFAULT (0) FOR [KaiJiang1],
CONSTRAINT [DF_KL10_KaiJiang2] DEFAULT (0) FOR [KaiJiang2],
CONSTRAINT [DF_KL10_KaiJiang3] DEFAULT (0) FOR [KaiJiang3],
CONSTRAINT [DF_KL10_KaiJiang4] DEFAULT (0) FOR [KaiJiang4],
CONSTRAINT [DF_KL10_Kaijiang5] DEFAULT (0) FOR [Kaijiang5]
GO
- 1楼网友:低音帝王
- 2021-04-15 20:18
首先是创建你需要的数据库,使用语言为CREATE DATABASE 数据库名
接着是创建对应的表,使用语句CREATE TABLE 表名
你表创建的多,表之间的关联多,那你的数据库就越复制
而且,你创建表的时候也可以把所有的表的信息多写在数据库的存储过程中
一个执行就给你全部创建好