点点滴滴(Oracle)
insert into
select * into t_dest from t_src; -- 要求目标表不存在
insert into t_dest(a, b) select a, b from t_src; -- 要求目标表已存在
动态SQL
execute immediate 'select ' || sq_serialnum || '.nextval from dual' into i_serialnum;
按照拼音,部首,笔画排序
下面的方法需要ORACLE9i和以上的版本才支持.
Oracle9i之前, 中文是按照二进制编码进行排序的.
在oracle9i中新增了按照拼音,部首,笔画排序功能. 设置NLS_SORT值
SCHINESE_RADICAL_M 按照部首(第一顺序),笔划(第二顺序)排序
SCHINESE_STROKE_M 按照笔划(第一顺序),部首(第二顺序)排序
SCHINESE_PINYIN_M 按照拼音排序, 系统的默认排序方式为拼音排序
select * from table_name order by nlssort(field_name, 'nls_sort=SCHINESE_STROKE_M');
取毫秒(oracle 9i +)
select to_char(systimestamp,'yyyy-mm-dd hh24:mi:ss.ff3') from dual;
like查询下划线本身
select * from test where columnname like 'a\_%' escape '\';
-- 表示将紧跟在escape字符后的字符解释为字符本身, 而非转义字符
日期减去一秒
select sysdate,sysdate - interval '1' second from dual;
修改表结构
alter table t_employee add (remark varchar2(50)); --增加列
alter table t_employee modify (sex default 0); --修改列的默认值
alter table t_employee modify (remark null); --修改列可为空
alter table t_employee rename to t_employee_new; --修改表名
&
相关文档:
oracle实例名,服务名等概念区别与联系
一、数据库名ITPUB个人空间v{7x6lo\
什么是数据库名?ITPUB个人空间*s*R5LVBXZ2w$I
数据库名就是一个数据库的标识,就像人的身份证号一样。他用参数DB_NAME表示,如果一台机器上装了多全数据库,那么每一个数据库都有一个数据库名。在数据库安装或创建完成之后,参 ......
oracle8i 驱动 ojdbc14.jar 这个驱动有问题,分页时要手动 写 rownum<m ,它自动成生的分页不正确,用的mysql的top m
Null value was assigned to a property of primitive 把entity中int类型改成Integer 库中不设置nullable
number(9) 的id 不能用Interger,得用BigDecimal,要不然取id时会报错 ......
Flashback 技术是以Undo segment中的内容为基础的, 因此受限于UNDO_RETENTON参数。要使用flashback 的特性,必须启用自动撤销管理表空间。
在Oracle 10g中, Flash back家族分为以下成员: Flashback Database, Flashback Drop,Flashback Query(分Flashback Query,Flashback Version Query, Flashback Transaction Que ......
1. 创建普通用户
>create user username identified by username;
>grant create tablespace, resource ,connect to username;
2. 创建表空间和用户
2.1 创建临时表空间
>create temporary tablespace DB_TEMP
tempfile '/opt/oracle/oradata/mydb/t ......
1. 将数据库完全导出
用户名system 密码system 导出到Oracle用户目录下的testdb20100522.dmp文件中
#exp system/system@testdb file=testdb20100522.dmp full=y
2. 将数据库中system用户与sys用户的表导出
#exp system/system@testdb file= testdb20100522.d ......