Oracle基础-数据表

Reading Time:The full text has 163 words, estimated reading time: 1 minutes
Creation Date:2017-07-21
Article Tags:
Previous Article:Python模块学习1-csv
Next Article:Oracle基础-表空间
 
BEGIN
  1. 创建表
create table tb_name(
    id number(1000, 0),
    haha varchar2(500),
    create_at date
)
  1. 增加字段:alter table tb_name add col_name varchar2(500);
  2. 修改字段:alter table tb_name modify col_name varchar2(50);
  3. 删除字段:alter table tb_name drop column col_name;
  4. 字段改名:alter table tb_name rename column col_name to col_name_new;
  5. 表改名:rename tb_name to tb_name_new;
  6. 清除表数据1:delete from tb_name;
  7. 清除表数据2:truncase table tb_name;删除速度比delete快很多,在citusdata中用来清除表及和此表所有关联表的内容。
  8. 复制表数据:
--1.建表时复制
create table tb_name as
select * from tb_name_oragin;
--2.建表后复制
insert into tb_name(id)
select id from tb_name_oragin;
  1. 更新数据:
update tb_name
set col_name = value
where 条件;
  1. 删除数据:delete from tb_name where 条件;
FINISH
Previous Article:Python模块学习1-csv
Next Article:Oracle基础-表空间

Random Articles
Life Countdown
default