常用SQL整理
1、添加一个或多个字段:
alter table tableName add column1 int(12) DEFAULT NULL; alter table tableName add (column1 int(12) DEFAULT NULL, column2 float(12,2) DEFAULT 0, column3 varchar2(10) DEFAULT null, ...);
2、删除一个或多个字段:
alter table tableName drop column1; alter table tableName drop (column1, column2, column3, ...);
3、更新字段:
update tableName set column1=1, column2=1, ... where condition;
4、添加表、字段注释:
comment on table tableName is '***'; comment on column tableName.columnName is '***';
5、锁表查询:
select sess.sid, sess.serial#, lo.oracle_username, lo.os_user_name, ao.object_name, lo.locked_mode from v$locked_object lo, dba_objects ao, v$session sess where ao.object_id = lo.object_id and lo.session_id = sess.sid;
6、查看oracle字符集
select userenv('language') from dual;
7、数据库操作