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最小的记录