zoukankan      html  css  js  c++  java
  • Oracle 修改表 Alter Table...

    --增加列
    ALTER TABLE Student add sex number(2);
    --删除列
    ALTER TABLE Student drop column sex;
    --更改列属性
    ALTER TABLE Student modify city number(2);
    --更改默认值
    ALTER TABLE Student modify sex default 1;
    --增加表主键
    ALTER TABLE Student add constraint stu_pk primary key(student_id);
    --增加表外键
    ALTER TABLE Student add constraint stu_ref
    foreign key(school) references school(schoolid);
    --更改非空约束
    ALTER TABLE Student modify sname not null;
    --增加检查约束
    ALTER TABLE Student add constraint check_stu_age check (age>10);
    --增加唯一性
    ALTER TABLE Student add constraint uqe_phone unique (phone);
    --删除约束
    ALTER TABLE Student drop constraint uqe_phone;
    --约束失效
    ALTER TABLE Student disable constraint uqe_phone;
    --约束复效
    ALTER TABLE Student enable constraint uqe_phone;
    --修改表名
    ALTER TABLE Student RENAME TO Student2
    --修改表列名
    ALTER TABLE Student RENAME COLUMN phone TO phoneno
    --表备注 Add comments to the table
    comment on table STUDENT
    is '学生';
    --字段备注 Add comments to the columns
    comment on column STUDENT.sname
    is '姓名';

  • 相关阅读:
    Python 基础之函数初识与函数参数
    python 基础之浅拷贝与深拷贝
    Python 基础之集合相关操作与函数和字典相关函数
    Python 基础之字符串操作,函数及格式化format
    Rocket
    Rocket
    Rocket
    Rocket
    Rocket
    Rocket
  • 原文地址:https://www.cnblogs.com/walkwithmonth/p/6306793.html
Copyright © 2011-2022 走看看