Skip to content

示例数据库脚本

xcli edited this page Nov 20, 2018 · 14 revisions

MySql Database

-- Create Database 
USE mysql;
CREATE DATABASE IF NOT EXISTS `g_main_test` DEFAULT CHARSET utf8 COLLATE utf8_general_ci; 
 
-- Create Table 
USE `g_main_test`;
DROP TABLE IF EXISTS user_info;

CREATE TABLE user_info (
  `user_id` INT (11) NOT NULL AUTO_INCREMENT COMMENT '用户Id', 
  `user_name` VARCHAR (255) DEFAULT NULL COMMENT '用户名', 
  `user_type_id` INT (11)  NULL COMMENT '所属类型', 
  `password` VARCHAR (255) DEFAULT NULL COMMENT '密码', 
  `login` INT (11)  NULL COMMENT '客户号', 
  `level` VARCHAR (255) NULL COMMENT '等级 VIP1,VIP2,VIP3 ',
  `group` VARCHAR (255) NULL COMMENT '小组 GROUP1,GROUP2,GROUP3 ',
  `status` TINYINT(4) DEFAULT 0 COMMENT '状态 0-正常 1-无效',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `value` VARCHAR (255) NULL COMMENT  '',
  PRIMARY KEY (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息';


CREATE TABLE user_type (
  `id` INT (11) NOT NULL AUTO_INCREMENT COMMENT '类型ID', 
  `name` VARCHAR (255) DEFAULT NULL COMMENT '类型名称',  
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户类型';

SqlServer Database (2008R2)

-- CREATE Database
USE master;
-- Create Database 
IF EXISTS(SELECT * FROM sys.databases where name = 'g_main_test')
DROP DATABASE g_main_test
GO
-- Create Table
USE [g_main_test]
GO
IF EXISTS(SELECT * from sysobjects where id = object_id('user_info') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE user_info
GO
CREATE TABLE  [user_info](
	[user_id] [int] IDENTITY(1,1) PRIMARY KEY  NOT NULL,
	[user_name] [varchar](255) NULL,
	[user_type_id] [int] NULL,
	[password] [nvarchar](255) NULL,
	[login] [int] NULL,
	[level] [varchar](255) NULL,
	[group] [varchar](255) NULL,
	[status] [int] NULL,
	[create_time] [datetime] NULL
)
GO
SET ANSI_PADDING OFF
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户信息' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info', @level2type=N'COLUMN',@level2name=N'user_id'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info', @level2type=N'COLUMN',@level2name=N'user_name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info', @level2type=N'COLUMN',@level2name=N'user_type_id'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info', @level2type=N'COLUMN',@level2name=N'password'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info', @level2type=N'COLUMN',@level2name=N'login'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'等级 VIP1,VIP2,VIP3 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info', @level2type=N'COLUMN',@level2name=N'level'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'小组 GROUP1,GROUP2,GROUP3' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info', @level2type=N'COLUMN',@level2name=N'group'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态 0-正常 1-无效' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info', @level2type=N'COLUMN',@level2name=N'status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_info', @level2type=N'COLUMN',@level2name=N'create_time'
GO  
IF EXISTS(SELECT * from sysobjects where id = object_id('user_type') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE user_type
GO
CREATE TABLE  [user_type](
	[id] [int] IDENTITY(1,1) PRIMARY KEY  NOT NULL,
	[name] [varchar](255) NULL, 
	[create_time] [datetime] NULL
)
GO
SET ANSI_PADDING OFF
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_type'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类型Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_type', @level2type=N'COLUMN',@level2name=N'id'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'类型名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_type', @level2type=N'COLUMN',@level2name=N'name'
GO 
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'user_type', @level2type=N'COLUMN',@level2name=N'create_time'
GO
Clone this wiki locally