zoukankan      html  css  js  c++  java
  • 表属性修改

    1.修改表名

    (1)mysql

    rename table table1 to table2;

    (2)SQL SERVER

    EXEC sp_rename 'table1', 'table2';

    (3)Oracle

    alter table table1 rename to table2

    (4)db2

    rename table table1 to table2;

    2.sql修改字段属性

    (1)修改字段名

    alter table 表名 rename column A to B

    (2)修改字段类型

    alter table 表名 alter column 字段名 type not null

    (3)修改字段默认值
    alter table 表名 add default (0) for 字段名 with values

    如果字段有默认值,则需要先删除字段的约束,在添加新的默认值,根据约束名称删除约束

    alter table 表名 drop constraint 约束名

    根据表名向字段中增加新的默认值

    alter table 表名 add default (0) for 字段名 with values

    (4)增加字段

    alter table 表名 add 字段名 type not null default 0

    (5)删除字段

    alter table 表名 drop column 字段名;

    3.mysql修改字段属性

    (1)修改字段类型

    alter table 表名 modify 字段名  数据类型  [属性][位置]

    (2) 修改表选项:校队集,字符集,存储引擎

    alter  table 表名  表选项  [=]  值

    (3)新增字段

    alter  table  表名  add [column]  字段名  数据类型  [列属性][位置]

    (4)重命名字段

    alter table 表名 change 老字段   新字段  数据类型 [属性][位置];

    (5)删除字段

    alter table 表名 drop 字段名;

  • 相关阅读:
    硬件——STM32 , SN74HC573锁存器
    【模拟】【杂题】jzoj 6345. 【NOIP2019模拟2019.9.8】ZYB建围墙
    归并排序求逆序对
    归并排序求逆序对
    hdu 4135
    hdu 4135
    牛客小白月赛5 A-无关(relationship)
    牛客小白月赛5 A-无关(relationship)
    HDU4027:Can you answer these queries?
    HDU4027:Can you answer these queries?
  • 原文地址:https://www.cnblogs.com/aczy/p/10923358.html
Copyright © 2011-2022 走看看