阿凯加油 2021-08-23 18:56 采纳率: 90%
浏览 19
已结题

嵌入C中的SQL语句在两种数据库中不一样

informix中 EXEC SQL UPDATE table SET *=(:tdb_table) where
table是表 tdb_table是表的结构体 这种不报错

在oracle 里面 这句就报错了 ,只能一个字段一个字段的给赋值么?
EXEC SQL UPDATE table SET a=:tdb_table.a , b=:tdb_table.b

where

是这样么? informix 和oracle 还有什么区别呢??

  • 写回答

1条回答 默认 最新

  • StjpStjp 2021-08-23 19:00
    关注
    如果我的回答对你有帮助,请采纳,谢谢

    informix的:
    1、创建数据库
    eg1. 创建不记录日志的库testdb,参考语句如下:
    CREATE DATABASE testdb;
    eg2. 创建带缓冲式的记录日志的数据库testdb(SQL语句不一定在事务之中,拥有者名字不被用于对象的解析),参考语句如下:
    CREATE DATABASE testdb WITH BUFFERED LOG ;
    eg3. 创建无缓冲式的记录日志的数据库testdb(SQL语句不一定在事务之中,拥有者名字不被用于对象的解析),参考语句如下:
    CREATE DATABASE testdb WITH LOG ;
    eg4. 创建ANSI的数据库(记录日志时无缓冲,SQL总在事务之中,拥有者名字被用于对象的解析),参考语句如下:
    CREATE DATABASE testdb WITH LOG MODE ANSI;
    2、创建普通数据表
    普通数据表又被称为持久数据表,它在system catalog里注册。一个普通数据表可对多个session和connection。创建时可以指定dbspace。
    eg1、如下语句创建了一个集团信息表cti_vccinfo:
    create table cti_vccinfo(
    vccid CHAR ( 6 ) not null ,
    vccname VARCHAR ( 255 ),
    effective INTEGER default 0 not null ,
    agentmax INTEGER default 0 not null ,
    ivrmax INTEGER default 0 not null ,
    updatekey VARCHAR ( 30 ),
    primary key (vccid) constraint PK_CTI_VI
    );
    3、创建临时数据表
    临时数据表不在system catalog里注册。一个临时数据表只对对应的某个session或connection可见,在对应的session或connection结束时被自动清除。如果dbspace存在的话,临时数据表将建于临时dbspace中。缺省情况下,是没有日志的。临时数据表支持索引。
    eg1:如下创建一个customer_temp的表,语句如下:
    CREATE TEMP TABLE customer_temp (
    num SERIAL NOT NULL ,
    name CHAR ( 15 ),
    create_time DATETIME YEAR TO FRACTION( 3 )
    );
    eg2:也可以将正式表中customer中的数据通过select......into temp语句将数据导入到临时表中,如下实例创建了一个正式的表customer,并插入了三条数据,接着通过select....into temp语句将这个正式表中的数据导入到临时表customer_temp。
    首先,创建customer普通数据表,建表语句如下:
    CREATE TABLE customer (
    num SERIAL NOT NULL ,
    name CHAR ( 15 ),
    create_time DATETIME YEAR TO FRACTION( 3 )
    );
    接着,在普通数据表customer中插入三条记录,语句如下:
    insert into customer (name, create_time) values ( ' amigo ' , ' 2010-11-17 15:41:00 ' );
    insert into customer (name, create_time) values ( ' xiexingxing ' , ' 2010-11-17 15:42:00 ' );
    insert into customer (name, create_time) values ( ' amigoxie ' , ' 2010-11-17 15:43:00 ' );
    最后,通过select......into temp语句将普通数据表customer中的数据导入到临时表customer_temp中(注意:需要保证customer_temp表不存在,操作成功后,customer_temp中的字段为select出的字段),参考语句如下所示:
    SELECT num, name, create_time FROM customer into TEMP customer_temp;
    4、创建主键约束
    1)主键约束定义在一个数据列或一组数据列上;
    2)主键的值是不允许重复的;
    3)主键的值不允许为NULL。
    在2中的实例,创建了cti_vccinfo表,并指定了vccid为其主键,并将其取名为PK_CTI_VI,以方便进行删除操作。
    接下来看一个使用复合主键的实例,如下语句创建了cti_humantaskgroup表,该表的serviceid和agentid组成联合主键,首先看下该表的建表语句:
    create table cti_humantaskgroup (
    serviceid VARCHAR ( 30 ) not null ,
    agentid VARCHAR ( 30 ) not null ,
    priority INTEGER default 0 not null ,
    updatekey VARCHAR ( 30 )
    );
    如下的语句为该表的serviceid和agentid创建了唯一索引:
    create unique index Index_CTI_HTG on cti_humantaskgroup(
    serviceid ASC ,
    agentid ASC
    );
    5、创建引用约束
     1)一个数据表的主键可以被同一个数据表或其它数据库表使用。主键被引用的数据表被称为父表,引用了附表的主键的数据表被称为子表;
      2)如果在定义引用约束时使用了ON DELETE CASCADE,当把父表的数据行删除时,子表的相关数据行也会被自动删除。
    在4中的实例中,cti_humantaskgroup表中的serviceid为cti_humantask中的主键,引用约束可在创建表的时候指明,也可以创建完成后通过alter语句创建,参考语句如下:
    alter table cti_humantaskgroup
    add constraint foreign key (serviceid)
    references cti_humantask (serviceid) on delete cascade
    constraint FK_CTI_HTG_HT;
    读者可以注意点,如上语句加上了on delete cascade,表示在删除cti_humantask表时,数据库系统会自动删除子表cti_humantaskgroup中serviceid与之相同的数据。
    6、检查约束
    定义了检查约束后,数据库将数据赋给一个数据列之前将根据检查约束检查数据是否满足条件。
    例如创建一个student表,该表有id(学号)、name(姓名)、age(年龄)和birthday(出生日期)4个字段,age必须在5到35之间,则在创建该表时需要添加检查约束,建表语句参考如下:
    create table student (
    id VARCHAR ( 10 ) not null ,
    name VARCHAR ( 10 ) not null ,
    age INTEGER default 0 not null check (age between 5 and 35 ),
    birthday VARCHAR ( 8 )
    );
    若通过如下语句插入一条不满足age的检查约束的数据:
    insert into student values ( ' 1234 ' , ' amigo ' , 40 , ' 19821121 ' );
    运行后会出现如下提示信息:
    530 : Check constraint (ines.c2209_13601) failed.
    7、创建视图
    1)创建视图时使用select语句;
    2)视图在system catalog里注册;
    3)视图数据不被存储在磁盘上;
    4)对于一些数据表,可为不同的用户建立不同的视图;
    5)可配置存取权限。
    例如,创建一个student_age的视图,查出age在20~25的学生,语句如下:
    CREATE VIEW student_age
    (id, name, age, birthday)
    AS SELECT id, name, age, birthday FROM student WHERE age >= 20 and age <= 25
    若要查询视图中的数据,例如得到student_age视图中的数据,可通过select语句进行查询,参考如下:
    select * from student_age;
    若要删除student_age视图,语句如下:
    drop view student_age;
    8、查询语句
    我们使用select语句从数据库中查询数据,select语句的使用语法如下所示:
    SELECT 字段列表(各个字段之间用英文逗号隔开)
    FROM 表列表(多个表之间用英文逗号隔开)
    [ WHERE 查询条件 ]
    [ GROUP BY 字段列表 ]
    [ HAVING 条件 ]
    [ ORDER BY 字段列表 ]
    [ INTO TEMP 临时表的名称 ]
    例如查询student表中的所有数据,语句参考如下:

    select * from student;
    查询student表中的记录,语句参考如下:

    select count ( * ) from student;
    查询student表中的name和age字段,语句参考如下:

    select name, age from student;
    在查询语句中,可以使用关系运算符,可使用的关系运算符如下:
    1)=
    例如查询出student表中姓名为amigo的字段,语句参考如下:

    select * from student where name = ' amigo ' ;
    2)!=或<>
    例如查询出年龄不为23的记录,语句参考如下:

    select * from student where age != 23 ;
    3)>
    例如查询出年龄大于23的记录,语句参考如下:

    select * from student where age > 23 ;
    4)>=
    大于等于,与大于使用方法类似。
    5)<
    小于,与大于使用方法类似。
    6)<=
    小于等于,与大于使用方法类似。
    在where语句中,可使用的关键字如下所示:
    1)AND(逻辑与)
    例如,当需要在student表中查出name为amigo,并且学号为1000的记录,此时可以使用AND,参考语句如下:

    select * from student where name = ' amigo ' and id = ' 1000 ' ;
    2)OR(逻辑或)
    例如,需要查询name为amigo,或者name为xingxing的记录,因为是或的关系,所以可以使用OR,参考语句如下:

    select * from student where name = ' amigo ' or name = ' xingxing ' ;
    3)[NOT] BWTWEEN([不]在......之间)
    例如,查找student表中age在24和30之间的记录的id、name和age字段,参考语句如下:

    select id, name, age from student where age between 24 and 30 ;
    4)[NOT] IN([不]在....中)
    [NOT] IN后可以是一个具体的值,也可以是一个子查询。
    例如,查找student表中的name不在“amigo”和“xingxing”的记录的id和name字段,参考语句如下:

    select id, name from student where name not in ( ' amigo ' , ' xingxing ' );
    5)IS [NOT] NULL:[不]是NULL
    例如需要查询出student表中birthday不为空的记录,参考语句如下:

    select * from student where birthday is not null ;
    6)[NOT] MATCHES:[不]匹配
    “?”表示匹配单个字符,“*”表示0到正整数个字符。
    例如,查找总共为5个字符,而且后4个字符为migo的记录,参考语句如下:

    select id, name from student where name matches ' ?migo ' ;
    例如,查找student表中以go结尾的任意长度的记录,参考语句如下:

    select * from student where name matches ' *go ' ;
    7)[NOT] LIKE:[不]匹配
    使用方法与[NOT] MATCHES类似,但是是使用“_”表示单个字符,“%”表示0到正整数个字符。
    GROUP BY
    我们可以使用group by对查询结果进行分组。分组后我们可以得到各个分组的统计消息,例如平均值、总和、数据行数等。
    例如,需要根据detail(详细情况分类)分组查询CTI_CallStat表中taskid为000001200002111864的记录,并将每种detail的数量显示出来,语句参考如下:

    select detail, count ( * ) as ratio from CTI_CallStat where taskid = ' 000001200002111864 ' group by detail
    CASE子句
    我们可以使用CASE表达式对返回值进行转换,CASE表达式的语法如下:

    CASE (expr)
    WHEN expr1 THEN result1
    WHEN expr2 THEN result2

    ELSE result_else
    END
    上面的CASE表达式的意思是:
    当expr为expr1时,返回result1;
    当expr为expr2时,返回result2;
    ...
    当expr为其它情况时,返回result_else.
    例如查询student表,当age为1时,显示为too little,100时,显示为too old,其余的情况显示为normal,参考语句如下:

    select id, name, age,
    case age
    when 1 then ' too little '
    when 100 then ' too old '
    else ' normal '
    end
    ageinfo
    from student;
    DECODE
    我们可以使用DECODE函数对返回值进行转换,DECODE函数的语法如下:

    DECODE (expr,
    expr1, result1,
    expr2, result2,

    result_else)
    上面的DECODE函数的意思搜:
    当expr为expr1时,返回result1;
    当expr为expr2时,返回result2;
    ...
    当expr为其它情况时,返回result_else。
    该函数能达到CASE子句类似的功能,例如达到前面的功能,可使用如下的DECODE语句:
    SELECT id, name, age,
    DECODE (age,
    1 , ' too little ' ,
    100 , ' too old ' ,
    ' normal ' )
    ageinfo
    FROM student;
    UNION和UNION ALL
    如果两个或多个select语句的结果相似,我们可以用“union”或“union all”把这些select语句合并起来。“union”和“union all”的区别是:“union”将去掉结果中的非第一次出现的值,而“union all”将保留结果中的非第一次出现的值。
    表连接的语法
    我们可以使用两种方式进行数据表连接:
    1)数据表之间使用逗号,连接条件前使用WHERE;
    2)数据表之间使用JOIN,连接条件前使用ON。
    第一种方式的参考实例如下:

    SELECT order_num, order_time, c.customer_num
    FROM customer c , orders o
    WHERE c.customer_num = o.customer_num;
    第二种方式的参考实例如下:

    SELECT order_num, order_time, c.customer_num
    FROM customer c JOIN orders o
    ON c.customer_num = o.customer_num;
    外连接
    例如,有两个表,员工表和项目表,员工可以负责项目,项目也可以有负责人(员工)。
    若想知道:那个员工负责哪个项目,哪些员工不负责项目,可以使用左外连接,参考语句如下:

    select e.employee_num, employee_name, project_num, project_name
    from employee e LEFT OUTER JOIN project p ON e.employee_num = p.employee_num
    若想知道:哪个员工负责哪个项目,哪些项目没有人负责,可以使用右外连接,参考语句如下:

    select e.employee_num, employee_name, project_num, project_name
    from employee e RIGHT OUTER JOIN project p ON e.employee_num = p.employee_num
    若想知道:哪个员工负责哪个项目,哪些员工不负责项目,哪些项目没有人负责,可以使用全连接,参考语句如下:

    select e.employee_num, employee_name, project_num, project_name
    from employee e FULL OUTER JOIN project p ON e.employee_num = p.employee_num
    子查询
    子查询分两种:相关子查询和不相关子查询。在相关子查询中,子查询中涉及到父查询的数据列;在不相关子查询中,子查询中不涉及到父查询的数据列。
    相关子查询实例:

    select * from customer
    where exists
    ( select * from vip
    where vip.customer_num = customer.customer_num);
    不相关子查询实例:

    select * from project
    where employee_num =
    ( select employee_num from employee where employee_name = ' amigo ' );
    在很多情况下,我们可以将相关字查询转换为表连接,这样数据库引擎有可能更方便的得到更优的查询计划,从而使SQL语句的执行时间更少。例如可将上面的相关子查询实例转换为:

    select customer. * FROM customer, vip
    where customer.customer_num = vip.customer_num;
    9、插入语句
    我们可以使用insert语句往数据表中插入数据行。
    如果各值按序赋给数据表中的所有数据列,则不需要指明数据列,例如往student表中插入数据,参考语句如下:

    insert into student values ( ' 1000 ' , ' amigo ' , 27 , ' 19821121 ' );
    如果是将值赋给指定数据列,则需指定数据列,例如只插入student表中的前三个字段,若使用如下的语句:

    insert into student values ( ' 1005 ' , ' amigo ' , 27 );
    此时会报错提示值的个数不正确,错误提示如下所示:

    236 : Number of columns in INSERT does not match number of VALUES .
    这时,需要指定数据列,参考语句如下:
    insert into student (id, name, age) values ( ' 1005 ' , ' amigo ' , 27 );
    可以在insert语句中嵌入select语句,从而将从一个或多个数据表查询来的数据插入到目标数据表。
    例如将student_bak表中age大于25的数据插入到student表中,参考语句如下:

    insert into student
    select id, name, age, birthday
    from student_bak where age > 25 ;
    10、更新语句
    可以使用update语句为数据表更新数据行。
    例如想将student中的id为1000的记录的name字段更新为amigo,age字段更新为28,语句参考如下:

    update student set name = ' amigoxie ' , age = 28 where id = ' 1000 ' ;
    使用如下的写法也是等效的:

    update student set (name, age) = ( ' amigoxie ' , 28 ) where id = ' 1000 ' ;
    11、删除语句
    可以使用delete语句从数据表中删除数据行。
    例如,删除student表中的所有数据,参考语句如下:

    delete from student;
    例如,删除student表中id为1001的数据,参考语句如下:

    delete from student where id = ' 1001 ' ;
    例如,删除student表中以go结尾的记录,参考语句如下:

    delete from student where name matches ' *go ' ;





    oracle:
    Oracle:基本SQL
    /*
    --以下代码是对emp表进行显示宽度设置
    col empno for 9999;
    col ename for a10;
    col job for a10;
    col mgr for 9999;
    col hiredate for a12;
    col sal for 9999;
    col comm for 9999;
    col deptno for 99;
    set pagesize 20;

    --创建新表new_emp,复制emp表中的结构和数据到new_emp表中
    create table xxx
    as
    select * from emp;

    --删除xxx表
    drop table xxx purge;
    */

    oracle数据库服务器由二个部分组成:
    A)数据库(物理概念,底层是数据库专用文件的集合)
    B)数据库实例(逻辑概念,只能能通过数据库实例操作数据库)

    SQL
    A) DML(数据操纵语言,例如:insert,update,delete,SELECT)
    B)DDL(数据定义语言,例如:create table,drop table,alter table)
    C) DCL(数据控制语言,例如:grant授予,revoke收权)
    D) TCL(事务控制语言,例如:rollback,commit,事务开始)


    以scott用户和123456密码进入oracle数据库实例
    sqlplus scott/123456;

    退出sqlplus环境
    exit

    查询scott用户下的所有表
    select * from tab;

    查询当前用户是谁
    show user;

    设置显示的列宽(字符型、日期型),10个字符宽度,a表示字符型
    col ename for a12;
    a12:表示显示宽度为12个字符,a大小写不敏感

    执行最近一次的SQL语句,并不是SQLPLUS命令
    /表示最近执行过的SQL语句
    col ename for a10,它不是SQL语句,而是oracle提供的专用SQLPLUS工具中的命令

    清屏
    host cls;

    SQLPLUS命令,可以简写,分号可省略
    SQL语句,不可简写,必须以分号结束

    查询emp表的结构
    desc emp;

    数字型:number
    字符型:varchar2
    日期型:date

    查询emp表的所有内容
    select * from emp;

    设置显示的列宽(数字型),9表示数字型,一个9表示一个数字位,四个9表示四个数字位
    col empno for 999999;
    col表示:column
    empno表示:列名
    for表示:format
    999999:表示显示6个字符宽度,只用于数字

    设置在一页中最多显示20条记录
    set pagesize 20;

    查询emp表的员工编号,姓名,工资,部门号
    select empno,ename,job,deptno from emp;

    查询emp表的不重复的工作
    select distinct job from emp;

    select distinct job,sal from emp;
    最终由job和sal的笛卡尔积决定

    查询员工的编号,姓名,月薪,年薪(月薪12)
    select empno,ename,sal,sal
    12 from emp;

    修改最近的一条SQL语句
    edit;

    查询员工的编号,姓名,月薪,年薪,年收入(年薪+奖金有空值)

    NULL运算数字=NULL

    解决null的问题,使用NVL()函数,NVL(a,b):如果a是空,用b替代

    null!=0
    null!=空白字符串

    使用别名,查询员工的编号,姓名,月薪,年薪,年收入(年薪+奖金)

    select empno "编号",ename "姓名",sal "月薪",sal12 "年薪",sal12+NVL(comm,0) "年收入"
    from emp;//正确

    使用字符串连接符号,输出"hello world",使用dual表

    dual表是oracle为了拼一些语言,而设计的一个哑表。
    因为oracle语法,有select子句,必须有from子句

    显示系统当前时间
    select now()这是mysql的语法
    select sysdate from dual;

    使用字符串连接符号,显示如下格式信息:xxxx的薪水是yyyy
    select ename || '的薪水' || sal "薪水情况" from emp;

    保存SQL语句到文件,并创建sql文件
    spool d:\1234.sql;

    保存SQL语句及其执行的结果
    spool off;

    执行文件中的sql语句,该文件必须是*.sql文件
    @ d:\1234.sql;

    单行注释

    多行注释
    /**/

    SQL vs SQLPLUS

    SQL
    1)语言
    2)ANSI标准
    3)关健字不可缩写
    4)必须是分号结束
    5)更新表中的数据

    SQLPLUS
    1)环境,命令
    2)是Oracle的特征之一
    3)关健字可缩写
    4)分号可有可无
    5)不能更新表中的数据

    HTML:
    JSP: <%-- --%>
    XML:
    Pros:#
    Java:
    A)//
    B)/* /
    C)/
    * /
    MySQL:#
    Oracle:
    A)--
    B)/
    /
    JS:
    A)//
    B)/
    /
    CSS:
    /
    */


    查询20号部门的员工
    select * from emp where deptno=20;

    查询姓名是SMITH的员工,字符串值,大小写敏感
    select * from emp where ename='SMITH';
    不敏感:表名、字段名,'A'
    敏感:字符串常量值

    查询1980年12月17日入职的员工,"17-12月-80"满足oracle默认日期格式(DD-MON-RR表示2位的年份)
    select * from emp where hiredate='17-12月-80';

    查询工资大于1500的员工
    select * from emp where sal > 1500;

    查询薪水在1300到1600之间的员工,包括1300和1600
    select * from emp where sal between 1300 and 1600;

    查询入职时间在"20-2月-81"到"23-1月-82"之间的员工
    select * from emp where hiredate between '20-2月-81' and '23-1月-82';

    查询20号或30号部门的员工
    select * from emp where deptno in(20,30);
    select * from emp where deptno = 20 or deptno = 30;

    查询姓名以"S"开头的员工
    select * from emp where ename like 'S%';

    %表示:0个,1个,多个字符

    _表示:1个字符

    查询姓名以"N"结束的员工,%表示0个,或多个字符
    select * from emp where ename like '%N';

    查询姓名是4个字符的员工,下划线只能表示1个字符
    select * from emp where ename like '
    ___';

    查询员工姓名中含有'_'的员工,让\后的字符回归本来意思【like '%_%' escape ''】
    select * from emp where ename like '%a%';

    查询佣金为null的员工
    select * from emp where comm is null;

    查询无佣金且工资大于1500的员工
    select * from emp where sal>1500 and comm is null;

    查询工资是1500或,3000或5000的员工
    select * from emp where sal in (1500,3000,5000);

    查询职位是"MANAGER"或职位不是"ANALYST"的员工(方式一)
    select * from emp where job='MANAGER' or not job = 'ANALYST';

    查询职位是"MANAGER"或职位不是"ANALYST"的员工(方式二)
    select * from emp where job='MANAGER' or job !='ANALYST';

    查询员工信息(编号,姓名,月薪,年薪),按月薪升序排序,默认升序
    select empno 编号,ename 姓名,sal 月薪,sal*12 年薪 from emp order by sal;

    查询员工信息,按入职日期降序排序
    select * from emp order by hiredate desc;

    查询员工信息,按佣金升序或降序排列,null值看成最大值
    select * from emp order by comm desc;
    select * from emp order by comm asc;

    查询员工信息,按工资降序排列,相同工资的员工再按入职时间升序排列
    select * from emp order by sal asc,hiredate desc;

    查询20号部门,且工资大于1500,按职入时间降序排列
    select * from emp where deptno=20 and sal>1500 order by hiredate asc;


    测试lower/upper/initcap函数

    测试concat/substr函数,从1开始 字符串连接,截取
    select concat('hello','world') from dual; 引号需要小写,一般可以使用||来连接
    select 'hello' || 'world' from dual;
    select substr('helloworld',1,5) from dual;

    测试length/lengthb函数,前提是,装oracle时,编码方式为UTF-8,一个中文占3个Byte长度
    select length('hahahahah宝贝') from dual;
    select lengthb('hahahahah宝贝') from dual;

    测试instr/lpad/rpad函数 计算w所在位置,从左边填充,从右边填充
    select instr('woaini','a') from dual;
    select lpad('a',10,'@') from dual;
    select rpad('a',10,'*') from dual;

    测试trim/replace函数 去处指定字符,替换指定字符
    select trim('w' from 'wwwwwhahawwww') from dual;
    select replace('foryangjin','yangjin','baobei') from dual;

    测试round/trunc/mod函数 四舍五入,截取,取余
    select round(95.126999,3) from dual;
    select trunc(95.126999,1) from dual;
    select mod(100,3) from dual;
    测试round作用于当前时间(month)
    select round(sysdate,'month') from dual;

    测试trunc作用于当前时间(month)
    12-3月-13
    select trunc(sysdate,'month') from dual;

    测试trunc作用于当前时间(year)
    select trunc(sysdate,'year') from dual;

    round和trunc除了用在数值型,也能用在日期型。

    测试sysdate,默认情况下,只显示日期部份,格式为:日-月-2位的年
    select sysdate from dual;

    显示昨天,今天,明天的日期,日期类型只能+-数值
    select sysdate-1 昨天,sysdate 今天,sysdate+1 明天 from dual;

    以年和月形式显示员工近似工龄,只能日期-日期=数值
    select ename 姓名,(sysdate-hiredate)/365 近似年工龄,(sysdate-hiredate)/30 近似月工龄 from emp;

    使用months_between函数,计算到年底还有多少个月
    select months_between('31-12月-13',sysdate) from dual;

    使用months_between函数,以精确月形式显示员工工龄
    select ename 姓名,months_between(sysdate,hiredate) as 员工精确工龄 from emp;

    测试add_months函数
    select add_months(sysdate,1) from dual;

    测试next_day函数,从今天开始算,下一个星期三是多少号?【中文平台】
    select next_day(sysdate,'星期日') from dual;

    测试last_day函数,本月最后一天是多少号?
    select last_day(sysdate) from dual;

    测试last_day函数,下一个月最后一天是多少号?
    select last_day(add_months(sysdate,1)) from dual;






    比较:
    1:[oracle]查看表空间

    select
    b.file_name 物理文件名,
    b.tablespace_name 表空间,
    b.bytes/1024/1024 大小M,
    (b.bytes-sum(nvl(a.bytes,0)))/1024/1024 已使用M,
    substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) 利用率
    from dba_free_space a,dba_data_files b
    where a.file_id=b.file_id
    group by b.tablespace_name,b.file_name,b.bytes
    order by b.tablespace_name

    2:oracle
    select into 如果不存在记录的时候会报错
    这个时候可以使用count(*)或者是max等来避免出错

    informix select into 如果不存在记录则该字段为null

    3:oracle执行存储过程是直接调用存储过程名称就行
    而informix则需要call 或者是execute procedure
    informix调用call 如果有错误只是会提示笼统错误。而execute则是提示具体错误

    并且如果informix 有 return 值 那么 execute procedure 就需要into一个接收变量,如果没有则报错

    4:oracle对varchar 和int类型 不是特别严谨,当给一个varchar 传递int类型的时候或者给int传递varchar

    oracle都会自动转换

    5:informix更新语句是Update tablename set(字段1,字段2)=(value1,value2);
    而oracle 的更新则是Set 字段一=value1,字段二=value2

    6:informix的赋值语句是let __TimeConfig=0;
    而oracle的赋值语句是:__TimeConfig :=0;

    7:对于判断是否存在,informix 可以用 exists直接在存储过程中调用,而不仅仅是select 语句中
    if exists(select 1 from gspmajor where majorid=M_MajorID) then
    let __IsGSPSHeet=1;
    end if
    oracle 则不行
    oracle 一般使用count 判断

    8:informix 可以在存储过程中直接创建临时表
    create temp table t_SumFeeInfo1
    (
    sumMemDiscRate dec(12,2),--VIP卡折扣率
    sumAllocateRate dec(12,2),--折扣费用分摊
    sumVipDDisc dec(12,2),--会员日折扣率
    sumVipAllocateRatedec(12,2),--会员日折扣分摊比
    sumMaterialFee dec(12,2),--能源物料使用费
    sumShopExtFee dec(12,2),--店铺扩展费
    sumTotalYearFee dec(12,2),--年度费用汇总
    sumGuarantyAmt dec(12,2)--保证金
    ) with no log;
    或者是直接select A.a1,A.a2 into temp tmp_mallccsheetashopgoods with no log;

    而oracle如果在存储过程中,则需要调用
    execute immediate
    'create GLOBAL TEMPORARY table tmp_orderdif(
    GoodsID int not null, --商品编码
    DiffQty dec(12,3) default 0 not null--验收差异量
    );
    drop table tmp_orderdif';

    9: informix 中 创建表的时候 最好指明扩展容量以及锁的模式

    但是 索引空间可以不需要

    create table rationref
    (
    sheetid varchar(20)not null,--配送单号
    Refsheetid varchar(20)not null,--配送通知单号
    RefSheetType int default 0 not null,--相关单类型 0=配送/返配单 1=退货通知单 2=直通订货单号
    RetShopID varchar(6), --退货地
    primary key (RefSheetID,sheetid,RefSheetType),
    foreign key (sheetid) references ration (sheetid)
    )extent size 1600 next size 1600 lock mode row;

    而oracle 创建表不需要设置,但是需要设置索引空间

    create table rationref
    (
    sheetid varchar(20)not null,--配送单号
    Refsheetid varchar(20)not null,--配送通知单号
    RefSheetType int default 0 not null,--相关单类型 0=配送/返配单 1=退货通知单 2=直通订货单号
    RetShopID varchar(10), --退货地
    primary key (RefSheetID,sheetid,RefSheetType) using index tablespace IDX_PCCOMS
    );

    10:oracle 给date 赋值的时候 需要使用default to_date('1900-01-01','yyyy-MM-dd')方式

    如果涉及到小时分钟和秒的话就要用 yyyy-MM-dd hh24:mi:ss;

    而informix则不需要default '1900-01-01' not null,

    如果我的回答对你有帮助,请采纳,谢谢
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月26日
  • 已采纳回答 4月18日
  • 创建了问题 8月23日

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)