【虚表dual】
数据库类型 | SQL 语句 |
ORACLE | select * from dual; |
DB2 | select * from SYSIBM.SYSDUMMY1; |
informix | create synonym dual for sysmaster: sysshmvals; select * from sysmaster: sysshmvals select first 1 mdy(month (today),01,year (today)) from sysams; select first 1 'a',1 from sysams; |
sqlserver | sql server不需要dual |
mysql | mysql 不需要dual |
GP | greenplum不需要dual |
【取系统时间】
数据库类型 | SQL 语句 |
ORACLE | select SYSDATE from DUAL; |
DB2 | select current date from SYSIBM.SYSDUMMY1; |
informix | select first 2 * from table_name |
sqlserver | select getdate(); |
mysql | select sysdate(); |
GP | select now(); |
【查询前十条记录】
数据库类型 | SQL 语句 |
ORACLE | select * from table_name where rownum < 10; |
DB2 | select * from dbu50.goods fetch first 1 rows only |
informix | select first 2 * from table_name |
sqlserver | select top X * from table_name order by colum_name desc |
mysql | select * from table_name limit 0,10 --0可以省略 |
GP | select * from table_name limit 0,10 |
山不在高,有仙则名;水不在深,有龙则灵。--《陋室铭》