1 彻底删除表:

ORACEL数据库基本操作SQL>  drop table tableName purge;
ORACEL数据库基本操作

2 清空回收站:

ORACEL数据库基本操作SQL> purge recyclebin;
ORACEL数据库基本操作

3 重命名表名或视图名:

ORACEL数据库基本操作SQL> rename oldtableName to newtableName;
ORACEL数据库基本操作

4 批量更新:

ORACEL数据库基本操作update talbe1 set table1.field2=(select field2 from table2 where table1.filed1=table2.field1);
ORACEL数据库基本操作

 

ORACEL数据库基本操作-- 把表table2的字段field1更新表tabel1的字段field1,条件为表table1的字段field2后六位等于table2的字段field2
ORACEL数据库基本操作
update table1 set table1.field1=(select table2.field1 from table2
ORACEL数据库基本操作
where substr( table1.field2,(length(table1.field2)-6+1),6 ) =substr( table2.field2,(length(table2.field2)-6+1),6 );

5 查询时间: 
 

ORACEL数据库基本操作(a)select to_char(clqssj,'yyyymmdd'as date1 from table1 where to_char(clqssj,'yyyymmdd'like '%2005101%';
ORACEL数据库基本操作 (b)
select clqssj as date1 from table1ORACEL数据库基本操作
         where clqssj between to_date('2005-10-09','yyyy-mm-dd'AND to_date('2005-10-11','yyyy-mm-dd') ;
ORACEL数据库基本操作

6 将一表中的数据备份到新表中:

ORACEL数据库基本操作create table  newtable as select * from oldtable;
ORACEL数据库基本操作

6 获取某一字段的后八位:

ORACEL数据库基本操作SELECT  NVL(field1,''AS field1, substr( NVL(field2,''),(length(NVL(field2,''))-8 +1),8 ) AS field2 FROM table1;ORACEL数据库基本操作


7 批量插入:

ORACEL数据库基本操作insert into table1 select * from table2;

8 查询重复记录:

ORACEL数据库基本操作SELECT A.field1 FROM table1 A
ORACEL数据库基本操作
GROUP BY CHINESENAMEA.field1 
ORACEL数据库基本操作
HAVING ( (SELECT COUNT(*FROM table1 BORACEL数据库基本操作  WHERE b.chinesename = a.chinesename    ) > 1    )  

9 在ORACLE 数据库中执行存储过程:

ORACEL数据库基本操作exec MY_PACKAGE.TABLE1_DELETE(参数1,参数2,ORACEL数据库基本操作,参数n);

 

11 给表增加字段:

ORACEL数据库基本操作alter table 表名 add (字段名 number(7,2));
ORACEL数据库基本操作
--添加或修改表或字段注释
ORACEL数据库基本操作
comment on column 表名.字段名  is '字段注释';
ORACEL数据库基本操作COMMENT 
ON TABLE 表名 IS '表注释';
ORACEL数据库基本操作

12查询某一方案下的所有对象:

ORACEL数据库基本操作(object_type='TABLE'查所有的表对象)
ORACEL数据库基本操作
select owner , object_name ,object_type from all_objects where OWNER = '用户名' and object_type='TABLE'
ORACEL数据库基本操作

13:在同一数据库复制表a,创建成表d:

ORACEL数据库基本操作select * into d from a

14:插入有日期类型的进行日期格式化:

ORACEL数据库基本操作--field1为DateTime数据类型
ORACEL数据库基本操作
INSERT INTO lqshduserinfo(field1) VALUES(To_date(field1,'YYYY-MM-DD HH24:MI:SS '))
ORACEL数据库基本操作


 

相关文章: