Tag Archives: oracle
Call to a member function on a non-object Oracle CLOB类型数据不能为null,否则php读取它的时候不能作为一个对象处理,而是当作null,所以对于值为null的CLOB数据的read() or size()函数都是无效的。
ORACLE对象大小写问题 在oracle建表的时候加双引号会阻止oracle自动将表名转为大写,但是还是默认使用大写好,免得以后后患无穷。
正则表达式 mysql字段转oracle一例
某mysql字段如下: `test_id` int(11) not null auto_increment comment '自增字段', 而且有大量的这样字段需要转到oracle,首先我们知道oracle的字段描述里面是没有comment的,但是同时也需要保留comment信息。使用正则表达式来转换,用notepad++正则表达式替换: 查找目标: comment(.*), 替换为: ,comment\1 \1表示的是(.*)的内容 最后替换为: `staff_id` int(11) not null auto_increment ,– '自增字段' 然后去掉反引号,去掉auto_increment,手动加上constraint primary key。
oracle给not null约束指定名称
一般我们建表结构的时候都是使用以下的形式: create table test( menuid number(8) default '0' not null, name varchar2(40) not null, id_parent number(10) not null, url varchar2(300) null, constraint pk_test primary key(menuid) ); 执行后,查看这个test表的所有约束: select constraint_name,table_name from user_constraints 发现命名都是SYS_CXXXXXX(XXXXXX表示数字),这些是oracle自动给约束的命名,我感觉为了提高以后数据库的可维护性,还是需要给not null约束指定名称,语法很简单: create table test( menuid number(8) default '0' … Continue reading
oracle没有create or replace table
SQL> create or replace table testTb; create or replace table testTb ORA-00922: 选项缺失或无效 只能使用先drop再create来代替 drop table testTb; create teble testTb( fid varchar2(4), fname varchar2(10) ); 可以用create or replace的对象有:functions, procedures, packages, types, synonyms, trigger and views,就是没有table,也没有sequence。 drop掉一个并不存在的表报错: SQL> drop table non_exists; … Continue reading
#167 codeigniter oci8 database driver do not support setting charset and session_mode while ocilogon() to oracle db
system/database/drivers/oci8/oci8_driver.php line 80 db_connect() function did not support set the charset and session mode while connecting to oracle db. function db_connect() { return @ocilogon($this->username, $this->password, $this->hostname); } function db_pconnect() { return @ocilogon($this->username, $this->password, $this->hostname); } here is the prototype of … Continue reading
codeigniter配置oracle数据库连接
Connection Parameters Not all of the parameters in application/config/database.php are used as one might expect. Namely, $db[‘default’][‘database’] isn’t used at all. The value used for $db[‘default’][‘hostname’] depends on whether the Oracle client’s tnsnames.ora file exists and contains information about the … Continue reading
4次重装oracle的教训(OracleDBConsoleORCL启动错误:系统错误3)
安装前请确定机子的ip不是dhcp获取的,否则当重新获得了ip,就无法连接,就杯具了。 最好是拔点网线,然后停用vmware的所有虚拟网站和无线网卡 D:\oracle\product\10.2.0\db_1 目录下有个x.x.x.x_orcl目录,那个x.x.x.x就是你安装时候oracle获取你的主机ip,如果获取的是dhcp ip就杯具了。如果是主机名_orcl或者是localhost_orcl就ok。不过我估计即便是被dhcp悲剧了也能手动修改回来的,我也尝试了,但是失败,应该还有我没有触及到的神秘文件。
修改oracle日期格式
oracle 10g中文默认的NLS环境变量如下: PARAMETER VALUE NLS_LANGUAGE SIMPLIFIED CHINESE NLS_TERRITORY CHINA NLS_CURRENCY ¥ NLS_ISO_CURRENCY CHINA NLS_NUMERIC_CHARACTERS ., NLS_CALENDAR GREGORIAN NLS_DATE_FORMAT DD-MM-RR NLS_DATE_LANGUAGE SIMPLIFIED CHINESE NLS_CHARACTERSET ZHS16GBK NLS_SORT BINARY NLS_TIME_FORMAT HH.MI.SSXFF AM NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF … Continue reading
Oracle分页
Oracle的分页查询语句基本上可以按照本文给出的格式来进行套用。 分页查询格式: SELECT * FROM ( SELECT A.*, ROWNUM RN FROM (SELECT * FROM TABLE_NAME) A WHERE ROWNUM <= 40 ) WHERE RN >= 21 其中最内层的查询SELECT * FROM TABLE_NAME表示不进行翻页的原始查询语句。ROWNUM <= 40和RN >= 21控制分页查询的每页的范围。 上面给出的这个分页查询语句,在大多数情况拥有较高的效率。分页的目的就是控制输出结果集大小,将结果尽快的返回。在上面的分页查询语句中,这种考虑主要体现在WHERE ROWNUM <= 40这句上。 选择第21到40条记录存在两种方法,一种是上面例子中展示的在查询的第二层通过ROWNUM <= 40来控制最大值,在查询的最外层控制最小值。而另一种方式是去掉查询第二层的WHERE … Continue reading