Oracle常用语句
--如何用grade表的资料去更新usertable表的资料(有关联的字段userid)
update usertable u set u.grade =
(select g.grade from grade g where g.userid = u.userid);
--如何使查询结果字段生成序号
select rownum, t.* from sm_t_pad_new t
--如何快速做一个和原表一样的备份表
create table new_table as (select * from user);
--如何查看数据文件的存放路径
select tablespace_name, file_id, bytes/1024/1024, file_name
from dba_data_files order by file_id;
--查询姓名相同的员工的信息
select u1.userid, u1.username from user u1,
(select username, count(*) from user group by username having count(username) > 1) u2
where u1.username = u2.username;
--根据时间查询
select * from user
where create_time >= to_date('2010-4-16 00:00:00','YYYY-MM-DD HH24:mi:ss')
and create_time <= to_date('2010-4-16 12:00:00','YYYY-MM-DD HH24:mi:ss')
相关文档:
首先查看数据库现有模式可使用以下语句
select name,log_mode from v$database;
也可以用下面的语句
archive log list;(该方法需要as sysdba)
对于非归档模式的数据库该为归档模式(主要以Oracle 10g为参考)使用以下步骤:
1. SQL> alter system set log_archive_dest_1='location=/oracle/oracle10g/log/archive ......
我们可以通过下面的语句来查询数据库的默认临时表空间:
SQL> select * from database_properties where property_name = 'DEFAULT_TEMP_TABLESPACE';
默认临时表空间的限制:
1. 默认临时表空间必须是TEMPORARY的:
SQL> alter database default temporary t ......
输入参数:str ——要截取的字符串, ch——要查找的字符串
截取ch之前(不包括ch)的字符串: substr(str, 0, instr(str, ch) - 1)
截取ch之后(不包括ch)的字符串: substr(str, , instr(str, ch) + 1, length(str)) ......
Oracle 的生产库都是启动在归档模式下,RAC下归档非归档的切换和单实例也是一样的,都是在MOUNT模式下执行ALTER DATABASE ARCHIVELOG/NOARCHIVELOG;命令。 不同的是:RAC环境下所有实例都必须处于非OPEN状态,然后在任意一个处于MOUNT状态的实例执行ALTER DATABASE命令,操作成功后,再正常启动 ......