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

    创建表:

    Create table username.table_name(/*username 可以没有*/

    Sid number(2) primary key,      /*定义主键 可以没有*/

    Nane varchar2(20) not null,

    Age number(3),

    Constraint sid primary key(sid)  /*或者添加约束,定义主键*/

    ) tablespace tablespace_name; /*表空间可以不指定*/

    修改表:

    添加列:

             Alter table table_name add column column_name column_type(n);

             A;ter table table_name add (column_name column_type(n),column_name column_type(n));

    删除列:

             Alter table table_name drop column column_name;

             Alter table table_name drop (column_name,column_name);

    更改列属性:

             Alter table table_name modify column_name new_column_type(n);

    更改表名:

             Alter table table_name rename to new_table_name;

    修改表所在的表空间:

             Alter table table_name move new_tablespace;

    删除表:

             Drop table table_name;

    表约束:

    创建表时:

             Create table table_name(

                       Sid number(3) primary key,

                       cid number(3) unique,

                       aid number(3) not null,

                       fid number(3) references table_name(priamry key));

    Not null:

     Alter table table_name modify aid null;

              Alter table table_name modify aid not null;

    Unique:

             Alter table table_name add unique(cid);

             Alter table table_name drop unique(cid);

             Alter table table_name add constraint constraint_name unique(cid);

             Alter table talbe_name drop constraint constraint_name

    Primary key:

             Alter table table_name add constraint constraint_name primary key(sid,cid);

             Alter table talbe_name drop constraint constraint_name;

    Foreign key:

             Alter table talbe_name add constraint constraint_name foreign key(cid) references table_name(primary key)

             Alter table table_name drop constraint constraint_name;

    Check:

             Alter table table_name add constraint constraint_name check(aid>3);

             Alter tabel table_name drop constraint constraint_name;

    Constraint:

             Alter table table_name disable constraint constraint_name;

             Alter table table_name enable constraint constraint_name;

             Alter table table_name modify constraint constraint_name enable;

             Alter table talbe_name modify constraint constraint_name disable;

  • 相关阅读:
    ios开发,NSFileManager的使用
    iOS开发-常用第三方开源框架介绍(绝对够你用了)
    iOS开发常用第三方开源框架
    对佛学和个人发展的思考总结(十八)心流、非人情网络、穷人、人生机会、平衡计分卡
    php 判断字符串中包含重复相同的次数 array_count_values str_split max 函数组合使用
    存储过程一次性返回多个数据集,逻辑层与前端处理
    动态改变div背景颜色
    在asp.net mvc应用中使用vue.js
    angularjs单一页面中高频访问相同web api,出现阻塞和等待
    Windows安装配置OpenGrok
  • 原文地址:https://www.cnblogs.com/kaibing/p/7861521.html
Copyright © 2011-2022 走看看