1. 查看oracle的版本信息:
Select version FROM Product_component_version
Where SUBSTR(PRODUCT,1,6)='Oracle';
Where SUBSTR(PRODUCT,1,6)='Oracle';
2. 查看数据库库对象: select owner, object_type, status, count(*) count# from all_objects group by owner, object_type, status;
3. 查看数据库的创建日期和归档方式: Select Created, Log_Mode, Log_Mode From V$Database;
4. 查看当前所有对象: select * from tab;
5. 建一个和a表结构一样的空表:
create table b as select * from a where 1=2;
create table b(b1,b2,b3) as select a1,a2,a3 from a where 1=2;
6. 查看数据文件放置的路径: select tablespace_name,file_id,bytes/1024/1024,file_name from dba_data_files order by file_id;
7. 连接字符串
select 列1||列2 from 表1;
select concat(列1,列2) from 表1;
8. 查询当前日期
select to_char(sysdate,'yyyy-mm-dd,hh24:mi:ss') from dual;
9. 用户间复制数据
copy from user1 to user2 create table2 using select * from table1;
10. 视图中不能使用order by,但可用group by代替来达到排序目的
create view a as select b1,b2 from b group by b1,b2;
11. 通过授权的方式来创建用户
grant connect,resource to test identified by test;
conn test/test
转载于:https://blog.51cto.com/tianya23/250109