zoukankan      html  css  js  c++  java
  • 表的操作

    创建用户自定义数据类型
    exec sp_addtype ower_char,'char(10)',null
    declare @date ower_char
    set @date='2012-12-31'
    select @date

    为自定义类型绑定默认值
    --exec sp_bindefault ower_char '2013-01-01'  
    删除用户自定义数据类型
    exec sp_droptype ower_char
    create table tab1
    (
    id int not null,
    name ut_name
    )
    go
    添加主键约束
    alter table tab1
    add constraint pk_tab1_id primary key(id)
    添加唯一约束
    alter table tab1
    add constraint un_tab1_name unique(name)
    添加字段
    alter table tab1
    add  score varchar(20)
    添加检查约束
    alter table tab1
    add constraint chk_score check(score>=0 and score<=100)
    alter table tab1 add dept varchar(20)
    添加默认约束
    alter table tab1
    add constraint def_dept default '计算机' for dept
    create table tab2
    (
    id1 int null,
    id2 int
    )
    添加外键约束
    alter table tab2
    add constraint FK_id1 foreign key (id1) references tab1(id)
    alter table tab1
    add telephone varchar(11)
    添加空值约束/修改字段
    alter table tab1
    alter column telephone varchar(11) not null

    删除字段
    alter table tab1   
    drop column telephone


    创建非聚集索引
    create clustered index IX_tab1_name on tab2(id2)
    查看索引
    sp_helpindex tab2
    修改索引名称
    sp_rename 'tab2.IX_tab1_name','IX_tab1_id1','index'
    删除索引
    drop index tab2.IX_tab1_id1

  • 相关阅读:
    Spark开发-SparkUDAF(二)
    Spark开发-Spark UDAF(一)
    Spark开发-Spark中类型安全UDAF开发示例
    Spark开发_构建TypeSafe的Dataset
    布隆过滤器(Bloom Filter)
    一个 Spark 应用程序的完整执行流程
    Spark的RPC
    Spark调优
    Hbase系列文章
    Flink怎么做到精确一次的?
  • 原文地址:https://www.cnblogs.com/rongxiaoya/p/2841539.html
Copyright © 2011-2022 走看看