zoukankan      html  css  js  c++  java
  • Sql Server 创建表(可重复执行--范本)

    use [GUOYOUZI.Study]
    
    if exists (select 1
       from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
       where r.fkeyid = object_id('UnitPriceDetail') and o.name = 'FK_UNITPRICEDETAIL_FK_BASICINFO')
    alter table UnitPriceDetail
       drop constraint FK_UNITPRICEDETAIL_FK_BASICINFO
    go
    
    if exists (select 1
                from  sysobjects
               where  id = object_id('UnitPriceDetail')
                and   type = 'U')
       drop table UnitPriceDetail
    go
    
    /*==============================================================*/
    /* Table: UnitPriceDetail                                       */
    /*==============================================================*/
    create table UnitPriceDetail (
       UnitID               int                  identity,
       BasicInfoID          int                  null,
       Title                nvarchar(50)         null,
       UnitAmount           decimal(18,8)        null,
       Remark               nvarchar(200)        null,
       constraint PK_UNITPRICEDETAIL primary key (UnitID)
    )
    go
    
    declare @CurrentUser sysname
    select @CurrentUser = user_name()
    execute sp_addextendedproperty 'MS_Description', 
       '价明细表(UnitPriceDetail)',
       'user', @CurrentUser, 'table', 'UnitPriceDetail'
    go
    
    declare @CurrentUser sysname
    select @CurrentUser = user_name()
    execute sp_addextendedproperty 'MS_Description', 
       '基础信息主键',
       'user', @CurrentUser, 'table', 'UnitPriceDetail', 'column', 'BasicInfoID'
    go
    
    declare @CurrentUser sysname
    select @CurrentUser = user_name()
    execute sp_addextendedproperty 'MS_Description', 
       '标题',
       'user', @CurrentUser, 'table', 'UnitPriceDetail', 'column', 'Title'
    go
    
    declare @CurrentUser sysname
    select @CurrentUser = user_name()
    execute sp_addextendedproperty 'MS_Description', 
       '单价金额',
       'user', @CurrentUser, 'table', 'UnitPriceDetail', 'column', 'UnitAmount'
    go
    
    declare @CurrentUser sysname
    select @CurrentUser = user_name()
    execute sp_addextendedproperty 'MS_Description', 
       '备注',
       'user', @CurrentUser, 'table', 'UnitPriceDetail', 'column', 'Remark'
    go
    
    alter table UnitPriceDetail
       add constraint FK_UNITPRICEDETAIL_FK_BASICINFO foreign key (ID)
          references BasicInfo (ID)
    go
  • 相关阅读:
    Python教程:从零到大师
    Hive 安装 & Mysql 安装
    Hive基本原理及配置Mysql作为Hive的默认数据库
    分布式存储系统-HDFS
    centos 6.4-linux环境配置,安装hadoop-1.1.2(hadoop伪分布环境配置)
    VirtualBox安装Centos出现E_FAIL (0x80004005)的解决方法
    Hadoop 中HDFS、MapReduce体系结构
    探索性测试及基本用例
    软件测试相关术语(测试策略 && 测试方案 ....)
    高效学习的疑问与思路[软技能]
  • 原文地址:https://www.cnblogs.com/JioNote/p/12145432.html
Copyright © 2011-2022 走看看