zoukankan      html  css  js  c++  java
  • (8)oracle 表的增删改

    表的命名

    表需要字母开头

    只能用如下字符 A-Z,a-z,0-9,$,#.

    不能使用oracle保留字

    长度不能超过30

    创建一张表

    create table 表名(字段名 数据类型,字段名 数据类型,......);

    create table student(id number(3),name varchar2(10),birthday date);

    添加字段

    alter table 表名(字段名 数据类型);

    alter table student add(score number(3));

    修改字段长度

    alter table 表名 modify(表名 字段名);

    alter table student modify(score number(4));

    修改字段名

    alter table tableName rename column oldCName to newCName;

    删除字段

    alter table 表名 drop column 字段名;

    alter table student drop column score;

    删除表

    drop table 表名;

    drop table student;

    修改表名

    rename table 旧表名 to 新表名;

    rename table student to class;

    表中添加数据

    insert into 表名 values(表数据,表数据,表数据);

    insert into student values(1,'tom','10-5月-1990');

    插入部分字段

    insert into 表名(字段名,字段名)values(表数据,表数据);

    insert into student(id,age)values(1,19);

    查赋值null的字段(赋值null和什么都不添是有区别的)

    select * from student where birthday is null;

    非空

    select * from student where birthday is not null;

    修改字段

    update 表名 set  字段名=aaa   where  另一字段=bbbb;

    update student set  name='如来佛' where age=9999;

    修改多字段

    update student set name=‘如来佛’ ,id=1 where  age=9999;

    删除表中数据

    delete  from 表名;    

    只删除表里的数据,可以恢复

    在删除表中的数据之前设置一个回滚点 savepoint a;  (把这个回滚点设成a,名字可以随便起)

    再需输入    rollback to a;  就能回到回滚点前的数据,可以有多个保存点。

     删除数据还可以用 truncate table 表名  这种删除方式不能找回数据,但删除速度快。

    给字段加中文注释

    COMMENT ON  COLUMN T_M2E_PUR_STOCK_IN.metering_code IS '检斤单号'
  • 相关阅读:
    立方和等式 考虑方程式:a^3 + b^3 = c^3 + d^3 其中:“^”表示乘方。a、b、c、d是互不相同的小于30的正整数。
    iOS 响应链
    Android驱动使用JNI调用
    [置顶] OGG01091 Unable to open file (error 89, Invalid file system control data detected)
    Unix 系统信号集与编程
    跟我一起玩Win32开发(23):渐变颜色填充
    android webservice 简单应用
    lisk之初发布
    美妙的微机原理2013/4/22
    android 腾讯微博登录小demo
  • 原文地址:https://www.cnblogs.com/buchizaodian/p/5672427.html
Copyright © 2011-2022 走看看