• (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 '检斤单号'
  • 相关阅读:
    POJ 2427 Smith's Problem Pell方程
    Codeforces Round #194 (Div. 2) 部分题解
    SPOJ 3899. Finding Fractions 连分数
    Codeforces Round #193 (Div. 2) 部分题解
    HDU 1402 A * B Problem Plus FFT
    F的ACM暑期集训计划
    HDU 4607 Park Visit HDU暑期多校1
    Windows 下 Sublime Text 默认打开方式问题解决办法
    Roman To Integer
    Longest Common Prefix
  • 原文地址:https://www.cnblogs.com/buchizaodian/p/5672427.html
Copyright © 2020-2023  润新知