sql server和mysql server sql语句对比
来源:互联网 发布:指向数组元素的指针 编辑:程序博客网 时间:2024/05/29 09:07
sql server/* 1.创建EmployeeInfo(雇员信息)表 */use myshopif exists(select * from sysobjects where name='EmployeeInfo')returncreate table EmployeeInfo( Eid int primary key not null, EName nvarchar(50) not null, Sex char(2) check (Sex in('男', '女')) default '女' not null, Age tinyint check (Age > 18) not null, -- 唯一值 Card char(18) unique not null, Phone nvarchar(11), Adress nvarchar(50), -- 默认值为系统日期 ToDate datetime default(getdate()) not null, Job nvarchar(8) not null)/* 2.创建UserLogin(用户登录)表 */if exists(select * from sysobjects where name='UserLogin')returncreate table UserLogin( Uid int foreign key not null, Eid int foreign key references EmployeeInfo(Eid) not null, UPassword nvarchar(50) not null)/* 2.创建MemberInfo(会员信息)表 */if exists(select * from sysobjects where name='MemberInfo')returncreate table Memberinfo( Mid int primary key not null, MName nvarchar(30) not null, Sex char(2)check(Sex in('男','女')) default '女' not null, Age smallint check(Age > 18) not null, Card char(18) unique not null, Phone nvarchar(11), Adress nvarchar(50), OnDate datetime default(getdate()) not null, WMid char(8) unique)/* 3.创建ProductInfo(产品信息)表 */if exists(select * from sysobjects where name='ProductInfo')returncreate table ProductInfo( Pid nvarchar(20) primary key not null, PName nvarchar(30) not null, Price real check(Price > 0) not null, JFen smallint check(JFen > 0) not null, Ptype nvarchar(30) not null) /* 4.创建ProductToInfo(产品入库登记)表 */if exists(select * from sysobjects where name='ProductToInfo')returncreate table ProductToInfo( ToId int IDENTITY (1, 1) primary key not null, Pid nvarchar(20) foreign key references ProductInfo(Pid) not null, Num smallint check (Num > 0) not null, ToDate datetime default(getdate()) not null, ForWho nvarchar(50) not null)/* 5.创建Stcok(库存信息)表 */if exists(select * from sysobjects where name='Stcok')returncreate table Stcok( Pid nvarchar(20) foreign key references ProductInfo(Pid) not null, -- 库存数量需要大于等于0 Num smallint check (Num >= 0) not null)/* 6.创建SellInfo(产品销售信息)表 */if exists(select * from sysobjects where name='SellInfo')returncreate table SellInfo( SIid int IDENTITY (1, 1) primary key not null, Pid nvarchar(20) foreign key references ProductInfo(Pid) not null, Num smallint check (Num > 0) not null, OutDate datetime default(getdate()) not null)/* 7.创建temp表 */if exists(select * from sysobjects where name='temp')returncreate table temp( Pid nvarchar(20) foreign key references ProductInfo(Pid) not null, Pname nvarchar(30) not null, Price real check (Price > 0) not null, Num smallint check (Num > 0) not null)
mysql serveruse myshop/* 1.创建EmployeeInfo(雇员信息)表 */delimiter //create table EmployeeInfo( Eid int primary key not null, EName nvarchar(50) not null, Sex char(2) default '女' not null, Age tinyint not null, -- 唯一值 Card char(18) unique not null, Phone nvarchar(11), Adress nvarchar(50), -- 默认值为系统日期 ToDate timestamp not null default current_timestamp, Job nvarchar(8) not null, check (Sex in('男', '女')), check (Age > 18))///* 2.创建UserLogin(用户登录)表 */delimiter //create table UserLogin( Uid int AUTO_INCREMENT primary key not null, UPassword nvarchar(50) not null, Eid int, foreign key (Eid) references EmployeeInfo(Eid))///* 3.创建MemberInfo(会员信息)表 */delimiter //create table Memberinfo( Mid int primary key not null, MName nvarchar(30) not null, Sex char(2) default '女' not null, Age smallint not null, Card char(18) unique not null, Phone nvarchar(11), Adress nvarchar(50), OnDate timestamp not null default current_timestamp, WMid char(8) unique, check(Sex in('男','女')), check(Age > 18))///* 4.创建ProductInfo(产品信息)表 */delimiter //create table ProductInfo( Pid nvarchar(20) primary key not null, PName nvarchar(30) not null, Price real not null, JFen smallint not null, Ptype nvarchar(30) not null, check(Price > 0), check(JFen > 0))// /* 5.创建ProductToInfo(产品入库登记)表 */delimiter //create table ProductToInfo( ToId int AUTO_INCREMENT primary key not null, Pid nvarchar(20) not null, Num smallint not null, ToDate timestamp not null default current_timestamp, ForWho nvarchar(50) not null, foreign key (Pid) references ProductInfo(Pid) , check (Num > 0))///* 6.创建Stcok(库存信息)表 */delimiter //create table Stcok( Sid int AUTO_INCREMENT primary key not null, Pid nvarchar(20) not null, -- 库存数量需要大于等于0 Num smallint not null, foreign key (Pid) references ProductInfo(Pid), check (Num >= 0))///* 7.创建SellInfo(产品销售信息)表 */delimiter //create table SellInfo( SIid int AUTO_INCREMENT primary key not null, Pid nvarchar(20) not null, Num smallint not null, OutDate timestamp not null default current_timestamp, foreign key (Pid) references ProductInfo(Pid), check (Num > 0) )///* 8.创建temp表 */delimiter //create table temp( id int AUTO_INCREMENT primary key not null, Pid nvarchar(20) not null, Pname nvarchar(30) not null, Price real not null, Num smallint not null, foreign key (Pid) references ProductInfo(Pid), check (Price > 0) , check (Num > 0))//
0 0
- sql server和mysql server sql语句对比
- MySQL和Sql Server的sql语句区别
- mysql和sql server
- mysql 和 sql server 的执行脚本对比
- MYSQL和MS SQL SERVER对比分析表
- MYSQL和MS SQL SERVER对比分析表
- MYSQL和MS SQL SERVER对比分析表 [转]
- SQL server和MYSQL中的自增的一些对比
- SQL Server、Oracle、MySQL和Vertica数据库常用函数对比
- sql server和mysql常用字段类型对比
- sql server和my sql 命令(语句)的区别,sql server与mysql的比较
- SQL Server与MySQL数据库对比
- SQL Server与MySQL数据库对比
- Oracle和SQL Server的对比 - 连接表的更新操作Update SQL 语句
- 常见数据库Sql Server,Oracle和MySQL的分页语句
- MySQL和SQL SERVER语句的一些区别
- MySQL、Oracle和SQL Server的分页查询语句
- SQL Server和Oracle常用函数对比
- Android Studio 常用快捷键
- Hadoop Shuffle
- Android—压缩图片,减少内存
- POJ-1942-Paths on a Grid-组合数学
- 【POJ2421】【最小生成树水题】【prim】
- sql server和mysql server sql语句对比
- Monitor线程操作(当一个线程中处于等待状态时,另外一个线程来解锁它的等待状态继续执行下去)
- Spring MVC控制层redirect
- 经典算法研究系列:九、图像特征提取与匹配之SIFT算法
- WINDOWS 内存管理笔记
- JDBC ORACLE 数据库隔离级别
- AndroidUniversalImageLoader使用详解
- Rust之语法<2>函数
- Git从远程的分支获取最新的版本到本地