db2,oracle,mysql³£ÓÃÃüÁî±È½Ï
¡¶oracle,db2,mysqlÀà±È¡·×÷ΪÈýÖÖÊý¾Ý¿âÒ»¸öÀà±È£¬Ä¿µÄÔÚÓÚͨ¹ýÀà±È£¬Á˽âÏÖÔÚÊý¾Ý¿âÏàËƵãÓëÒìͬµã£¬Í¬Ê±¿ÉÒÔ°ïÖú´ó¼ÒÔÚÁ˽âÒ»ÖÖÊý¾Ý¿â£¬Äܹ»Ñ¸ËÙµØѧ»áÆäËûÊý¾Ý¿â¡£³õ²½¶¨ÒåΪoracle,db2,mysqlÈýÖÖÊý¾Ý¿â£¬ÒÔºó¿ÉÄÜ»¹ÊÇ×·¼Óinformix,sysbase,sql serverµÈÊý¾Ý¿â¡£
±¾Æª×÷ΪÊ×ƪ£¬Ä¿µÄÊÇÈôó¼Ò¶ÔÕâÈýÖÖÊý¾Ý¿â³£ÓõÄ֪ʶµãÓÐÒ»¸ö¸ÐÖªµÄÈÏʶ¡£
Ò»¡¢³£ÓÃ֪ʶµã
1¡¢²é¿´¿ÉÒԵǽµÄÊý¾Ý¿â£º
oracle:²é¿´tnsname.ora »òÕß echo $ORACLE_SID
db2:
mysql:show databases --²é¿´µ±Ç°Êý¾Ý¿â£ºselect database()
2¡¢²é¿´Óû§±í£¬ÊÓͼ£¬±íË÷Òý£¬±íÁУ¬
oracle:
select table_name from user_tables;
select view_name from user_views;
select constraint_name,constraint_type from user_constraints where table_name='';
select column_name from all_tab_columns where table_name='';
db2:
list tables or select tabname from syscat.tables;
select view_name from syscat.views;
describe indexes for table table_name;
select tabname from syscat.columns where tabname='';
mysql:information_schema
select table_name from information_schema.tables where table_schema='USER'; or show tables;
select table_name from information_schema.views where table_schema='USER'; or show table status where comment='view';
select constraint_name,constraint_type from information_schedma.table_constraints where table_name='';
select index_name,table_name from information_schema.statistics where table_name='';
select column_name from information_schedma.columns where table_name='' and table_schema='USER';
3¡¢²é¿´±í¿Õ¼ä
oracle:select name from v$tablespace
db2: list tablespaces
mysql:
4¡¢²é¿´±í½á¹¹
oracle:describe table_name
db2:describe table table_name
mysql:describe table_name
5¡¢È¡Ç°nÐÐÊý¾Ý
oracle:select * from table_name where rownum<n
db2:select * from table_name fetch first n rows only
mysql:select * from table_name limit n
6¡¢loadÊý¾Ý
oracle: sqlldr username/passwd control=ctr.ctl data=data.txt
db2:load from data.txt of del insert into table_name
mysql:load data local infile 'e:Mysqlmysql.txt' into table test lin
Ïà¹ØÎĵµ£º
³ÉÔ±º¯ÊýºÍ¹ý³Ì
¹¹Ô캯Êý·½·¨
-oracleµÄÿ¸ö¶ÔÏó¾ùÓÐÒ»¸öÄÚÖõĹ¹Ô캯Êý·½·¨
-ÓÃÓÚ´´½¨¶ÔÏóµÄÒ»¸öʵÀý
-ÎÞÐèÏÔʽµØ¶¨Òå
-Óë¶ÔÏóÀàÐÍͬÃû
¶¨Òå¶ÔÏóÀàÐÍ
create or replace
type persontype as object
(
id int,
name varchar(20),
member function ......
OracleÊý¾Ýµ¼Èëµ¼³öimp/exp¾ÍÏ൱ÓÚoracleÊý¾Ý»¹ÔÓ뱸·Ý¡£expÃüÁî¿ÉÒÔ°ÑÊý¾Ý´ÓÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷µ¼³öµ½±¾µØµÄdmpÎļþ£¬impÃüÁî¿ÉÒÔ°ÑdmpÎļþ´Ó±¾µØµ¼Èëµ½Ô¶´¦µÄÊý¾Ý¿â·þÎñÆ÷ÖС£ ÀûÓÃÕâ¸ö¹¦ÄÜ¿ÉÒÔ¹¹½¨Á½¸öÏàͬµÄÊý¾Ý¿â£¬Ò»¸öÓÃÀ´²âÊÔ£¬Ò»¸öÓÃÀ´ÕýʽʹÓá£
Ö´Ðл·¾³£º¿ÉÒÔÔÚSQLPLUS.EXE»òÕßDOS£¨ÃüÁîÐУ©ÖÐÖ´Ð ......
ÔÚ$ORACLE_HOME/sqlplus/admin/login.sql (»òÕßÊÇglogin.sql)ÖÐÌí¼Ó£º
set termout off
COLUMN prompter new_value m_prompt
select host_name || ':' || instance_name ||' >' prompter
from sys.v_$insta ......
Ç°×¢£º¶ÔÓÚÕë¶Ô×Ö·û´®Î»ÖõIJÙ×÷£¬µÚÒ»¸öλÖñ»±ê¼ÇΪ1¡£
ASCII(str) ·µ»Ø×Ö·û´®strµÄ×î×óÃæ×Ö·ûµÄASCII´úÂëÖµ¡£Èç¹ûstrÊÇ¿Õ×Ö·û´®£¬·µ»Ø0¡£Èç¹ûstrÊÇNULL£¬·µ»ØNULL¡£
mysql> select ASCII('2');
-> 50
mysql> select ASCII(2);
-> 50
mysql> select ASCII('dx');
-> 1 ......
ÕâÀïÊÇÒ»¸öʹÓÃÈÕÆÚº¯ÊýµÄÀý×Ó¡£ÏÂÃæµÄ²éѯѡÔñËùÓÐ date_col ÖµÔÚ×îºó 30 ÌìÄڵļǼ¡£
mysql> SELECT something from tbl_name
WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30;
DAYOFWEEK(date) ·µ»Ø date µÄÐÇÆÚË÷Òý(1 = Sunday, 2 = Monday, ... 7 = Saturday)¡£Ë÷ÒýÖµ·ûºÏ ODBC µÄ±ê×¼¡£
mysq ......