oracle常用SQL语句

alter table alist_table add address varchar2(100);/* 向一个表格添加字段 */

alter   table   table1   drop   column   col1; /* 删除表里某列 */

update   table1   set   col2   =   col1 ;  /* 列col1的项复制到列col2 */

 

select * from tablename where a is NULL /*查找字段内容为空的记录*/

 

update table1 set col1=***  /修改字段col1的数据/

/* 修改字段 属性 字段为空 */

alter table alist_table modify address varchar2(80);

/* 修改字段名字 */

create table alist_table_copy as select ID,NAME,PHONE,EMAIL,

QQ as QQ2, /*qq 改为qq2*/

ADDRESS from alist_table;

drop table alist_table;

rename alist_table_copy to alist_table/* 修改表名 */

 

select   *   from   tablename   where   rownum<2 /*搜索表里TOP2记录*/

 

update tablename set clo=clo+n where ... /*将符合条件的数据+n*/

 

alter table TABLE_NAME add constraint KEY_NAME primary key (TABLE_COLUMN);增加主键,括号里可以加多个字段,即将多字段加上约束。


alter table TABLE_NAME  drop constraint KEY_NAME; 删除主键或外键

 

select * from slb.water a where (a.datetime,a.device_id) in (select a.datetime,a.device_id from slb.water group by a.datetime,a.device_id having count(*)>1);查找表中多余的重复记录(多个字段)

 

delete from slb.water a where(a.datetime,a.device_id) in(select a.datetime,a.device_id from slb.water group by a.datetime,a.device_id having count(*)>1)删除表中多余的重复记录(多个字段),只留有rowid最小的记录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值