zoukankan      html  css  js  c++  java
  • Sql Server创建表示例程序

        USE suntest  
    create table 仓库
    (
    仓库编号
    int ,
    仓库号
    varchar(50) ,
    城市
    varchar(50) ,
    面积
    int
    )
    create table 仓库1
    (
    仓库编号
    int not null ,
    仓库号
    varchar(50) not null,
    城市
    varchar(50) not null, --不能为空not null--
    面积 int
    )
    create table 仓库2
    (
    仓库编号
    int primary key , --主键的关键字primary key--
    仓库号 varchar(50) unique, --唯一索引关键字unique--
    城市 varchar(50) not null, --不能为空not null--
    面积 int
    )
    create table 仓库3
    (
    仓库编号
    int primary key , --主键的关键字primary key--
    仓库号 varchar(50) unique, --唯一索引关键字unique--
    城市 varchar(50) default '青岛', --不能为空not null--
    面积 int check (面积>=300 and 面积<=1800)
    )
    create table 职工表
    (
    职工编号
    int identity (1,1) primary key,
    职工号
    varchar(50) unique,
    仓库号
    varchar(50),
    工资
    int check(基本工资>=800 and 基本工资<=2100),
    )
    create table 订单表
    (
    订单编号
    int identity(1,1) primary key,
    订单号
    varchar(50) unique,
    职工号
    varchar(50) references 职工表(职工号),--references两张表通过“职工号”关联--
    订购日期 datetime,
    销售金额
    int
    )
    create table 阳光工资表
    (
    职工编号
    int identity (1,1) primary key,
    职工号
    varchar(50) unique,
    仓库号
    varchar(50),
    基本工资
    int check(基本工资>=800 and 基本工资<=2100),
    加班工资
    int,
    奖金
    int,
    扣率
    int,
    应发工资
    as (基本工资+加班工资+奖金-扣率) --as为自动计算字段,不能输入值--
    )
  • 相关阅读:
    204. Count Primes (Integer)
    203. Remove Linked List Elements (List)
    202. Happy Number (INT)
    201. Bitwise AND of Numbers Range (Bit)
    200. Number of Islands (Graph)
    199. Binary Tree Right Side View (Tree, Stack)
    198. House Robber(Array; DP)
    191. Number of 1 Bits (Int; Bit)
    190. Reverse Bits (Int; Bit)
    189. Rotate Array(Array)
  • 原文地址:https://www.cnblogs.com/edisonfeng/p/2171333.html
Copyright © 2011-2022 走看看