zoukankan      html  css  js  c++  java
  • SQL SERVER 查看表是否存在

    查看表是否存在

    if exists(select 1 from sysobjects where id = OBJECT_ID('数据库名称.dbo.表明称'))

      drop table

    为字段添加注释:

    EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'表明称', @level2type=N'COLUMN',@level2name=N'列明'

    创建表的时候,建立外间和唯一约束,下面是一个用户表和用户详细信息表

    create table member(

      memberid int primary key identity(1,1),--主键

      username varchar(30) not null unique,--唯一约束

      password varchar(40) not null

    )

    create table memberinfo(

      memberid int not null foreign key references member(memberid) unique,--外键和唯一约束

      email varchar(30),

      age int

    )

  • 相关阅读:
    kvm虚拟迁移(5)
    kvm虚拟化网络管理(4)
    计算系数
    排列组合
    错排
    加分二叉树
    皇宫看守
    战略游戏
    数字转换
    JDK8 HashMap源码分析
  • 原文地址:https://www.cnblogs.com/andysd/p/3173027.html
Copyright © 2011-2022 走看看