zoukankan      html  css  js  c++  java
  • oracle——数据表的相关操作——删除数据表

    创建数据表;
    
     create table 表名 ( 列明1 数据类型1 [约束性条件],
                         列明1 数据类型1 [约束性条件],
                        
                         ……
    
                        ) tablespace 表空间
    
    
    
    create table student05 ( student_id number not null,
                             student_name varchar2(20),
                             student_age number,
                             status varchar2(2),
                             version number default 0
                           ) tablespace test
    
    select * from student05;
    


    数据表的相关操作


    1、增加新列 alter table student 用于修改表的结构,add用于增加列,注意此处没有column关键字;小括号内是列以及列的数据类型; 用户可以一次性为表增加多个列,各列之间使用逗号进行分隔。 alter table student05 add( class_id number); alter table student05 add( tel number , address varchar2(50) ); select * from student05;




    2、修改已有列的数据类型 alter table student05 modify ( class_id varchar2(20 )); alter table student05 modify ( class_id number );




    3、删除已有列 alter table student05 drop column class_id;




    4、重新命名一个列名 alter table student05 rename column student_id to id; alter table student05 rename column id to student_id;




    对于调整数据表结构来说,要特别注意严谨性。 列的数据类型的修改,有可能会影响应用程序对数据库进行存取;列的删除和重命名更需要检查应用程序是否会出现关联性应用错误。




    5、如果数据表创建时,选择了错误的表空间,那么可以利用alter table命令,结合move tablespace选项转移表空间 alter table student05 move tablespace 其它表空间名;





    6、删除数据表 drop table student05; 有时,由于某些约束的存在。如,当前表的主键被其它表作为外键,会导致无法成功删除。利用 cascade constraints 选项,可以将约束同时删除,从而保证 drop table命令一定执行成功 drop table student05 cascade constraints;
  • 相关阅读:
    POJ 1015 Jury Compromise【DP】
    POJ 1661 Help Jimmy【DP】
    HDU 1074 Doing Homework【状态压缩DP】
    HDU 1024 Max Sum Plus Plus【DP,最大m子段和】
    占坑补题。。最近占的坑有点多。。。
    Codeforces 659F Polycarp and Hay【BFS】
    Codeforces 659E New Reform【DFS】
    Codeforces 659D Bicycle Race【计算几何】
    廖大python实战项目第四天
    廖大python实战项目第三天
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12257601.html
Copyright © 2011-2022 走看看