OCPÈÏÖ¤¿¼ÊÔÖ¸ÄÏ£¨4£©£º½ÓºÏOracleÊý¾Ý¿â
Ò»¡¢SQLµÄʹÓÃ
CREATE¡¢ALTERºÍDROPÊÇÖ÷ÒªµÄ3ÖÖDDLÓï¾ä£¬ÕâЩÓï¾ä±»ÓÃÓÚÔÚÊý¾Ý¿âÖÐÌí¼Ó¡¢Ð޸Ļòɾ³ý¶ÔÏó¡£
DCLÓï¾ä°üÀ¨GRANTºÍREVOKEÃüÁËüÃÇ¿ÉÒÔ±»ÓÃÓÚΪÓû§»ò½ÇÉ«ÊÚÓè»òÈ¡ÏûȨÏÞ£¬¿ÉÒÔ±»ÊÚÓèºÍÈ¡ÏûµÄÁ½ÖÖȨÏÞÊÇϵͳȨÏ޺ͶÔÏóȨÏÞ¡£È¡¾öÓÚ²»Í¬µÄ¶ÔÏóÀàÐÍ£¬¶ÔÏóȨÏÞ¿ÉÄܲ»Í¬¡£
²Ù×Ý»ò¼ìË÷Êý¾Ý¶¼ÐèҪʹÓÃDMLÓï¾ä¡£DMLµÄÖ÷ÒªÔªËØÊÇSELECT¡¢INSERT¡¢UPDATEºÍDELETEÃüÁDML»¹°üÀ¨ÓÉCOMMIT¡¢ROLLBACKºÍSAVEPOINTÃüÁî×é³ÉµÄÊÂÎñ¿ØÖÆÓïÑÔÔªËØ¡£
1¡¢SELECTÓï¾ä
»ù±¾¸ñʽÈçÏ£º
?[Copy to clipboard]View Code SQL
SELECT [DISTINCT] {* | column, [expression],...}
from table;
Àý×Ó£º
?[Copy to clipboard]View Code SQL
SQL> select username || 'is' || account_status as "User and Sstatus"
2 from dba_users;
1.1¡¢Ê¹ÓÃWHERE×Ó¾äÏÞ¶¨·µ»ØµÄÐÐ
ÔÚSELECTÓï¾äÖУ¬WHERE×Ó¾ä×ÜÊÇλÓÚfrom×Ó¾äÖ®ºó£º
?[Copy to clipboard]View Code SQL
SELECT [DISTINCT] {* | column, [expression],...}
from table;
[WHERE condition1 [{AND | OR [NOT]} condition2...] ]
Àý×Ó£º
?[Copy to clipboard]View Code SQL
SQL> select count(*) from dba_tables where owner = 'SYSMAN';
¼Çס£ºOracleÖ´ÐÐ×Ö·û±È½Ïʱ»áÇø·Ö´óСд¡£ÀýÈ磺
?[Copy to clipboard]View Code SQL
SQL> select count(*) from dba_tables where owner = 'sysman';
COUNT(*)
----------
0
SQL> select count(*) from dba_tables where owner = 'SYSMAN';
COUNT(*)
----------
337
1.2¡¢±ÜÃâ½á¹û¼¯ÖгöÏÖÖØ¸´
DISTINCT¹Ø¼ü×Ö¿ÉÒÔÓ¦ÓÃÓÚSELECTÁбíÖеÄËùÓÐÁлò±í´ïʽ¡£ÀýÈ磺
?[Copy to clipboard]View Code SQL
SQL> select distinct owner from dba_objects;
SQL> select distinct owner, object_type from dba_objects;
1.3¡¢´Ó¶à¸ö±íÖмìË÷Êý¾Ý
OracleÄܹ»Ö§³Ö´«Í³µÄÁ¬½ÓÓï·¨£¬²»¹ýÓ¦µ±Ê×Ñ¡ANSI JOINÓï·¨£¬ÏÂÃæÁ½ÖÖ£¬ÎÒÃǸüÍÆ¼öµÚ¶þÖÖ·½·¨¡£
?[Copy to clipboard]View Code SQL
SQL> select dba_data_files.tablespace_name, file_name
2 from dba_tablespaces, dba_data_files
3 where dba_tablespaces.tablespace_name=dba_data_files.tablespace_name;
SQL> select dba_data_files.tablespace_name, file_name
2 from dba_tab
Ïà¹ØÎĵµ£º
Oracleʱ¼äÈÕÆÚ²Ù×÷
sysdate+(5/24/60/60) ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Ãë
sysdate+5/24/60 ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5·ÖÖÓ
sysdate+5/24 ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Сʱ
sysdate+5 ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Ìì
add_months(sysdate,-5) ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5ÔÂ
add_months(sysdate,-5*12) ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Äê
ÉÏÔÂÄ©µÄÈÕÆÚ£ºsel ......
1¡¢±à³ÌÓïÑÔÓëOracleÊý¾Ý¿â
1.1¡¢´æ´¢µÄÓëÄäÃûµÄPL/SQL³ÌÐò¿é
Óë´æ´¢µÄPL/SQL³ÌÐò¿éÏà±È£¬ÄäÃûµÄPL/SQL³ÌÐò¿éЧÂʽϵͣ¬´ËÍâÓÉÓÚ¿ÉÄÜÔÚ¶ą̀»úÆ÷Öй«²¼Ô´´úÂ룬»¹»áÒý·¢¹ÜÀíÎÊÌâ¡£
1.2¡¢PL/SQL¶ÔÏó
PL/SQL¶ÔÏó¾ßÓÐÏÂÁÐ5ÖÖÀàÐÍ£º
¹ý³Ì
º¯Êý
³ÌÐò°ü
³ÌÐò°üÖ÷Ìå
´¥·¢Æ÷
2¡¢¹ý³Ì¡¢º¯ÊýÒÔ¼°³ÌÐò°ü
2.1¡¢¹ý³ÌÓëº¯Ê ......
ÏÈÀ´Á˽âϼ¸¸öÓ¢Îĵļò³Æ£¬ÔÚÒÔºó¾³£»á¼ûµ½¡£
¶ÔÏó¹ØÏµÊý¾Ý¿â¹ÜÀíϵͳ£¨Object Relational Database Management System£¬¼ò³ÆORDBMS£©
¹ØÏµÊý¾Ý¿â¹ÜÀíϵͳ£¨Relational Database Management System£¬¼ò³ÆRDBMS£©
Êý¾Ý¿â¹ÜÀíϵͳ£¨Database Management System£¬¼ò³ÆDBMS£©
½á¹¹»¯²éѯÓïÑÔ£¨Structured Query Langua ......
ÊÖ¶¯½¨¿âÆäʵҲ¿ÉÒÔ·ÖΪÁ½ÖÖ£¬Ò»ÖÖÊDz»Ê¹ÓÃOMF´´½¨£¬ÁíÒ»ÖÖÊÇʹÓÃOMF´´½¨¡£
Ò»¡¢²»Ê¹ÓÃOMFÊÖ¶¯´´½¨Êý¾Ý¿â
1¡¢´´½¨Îļþ¼Ð¡££¨¸ù¾Ý¸Õ²Å/ora01/db/oracle/admin/ocpÖеÄĿ¼£¬ÎÒÃÇҲͬÑù´´½¨£©
?[Copy to clipboard]View Code BASH
$ mkdir /ora01/db/oracle/admin/mydb
$ cd /ora01/db/oracle/admin/mydb
$ mkdir bdum ......