Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ORACLE PL/SQL ¼Ç¼(Record)ѧϰ±Ê¼Ç(Ò»)

ÔÚPL/SQL³ÌÐòÉè¼ÆÖУ¬ÓÐÈýÖÖ¶¨Òå¼Ç¼ÀàÐ͵ķ½·¨£ºÒ»ÖÖÊÇʹÓÃ%ROWTYPEÊôÐÔ£»ÁíÒ»ÖÖÊÇÔÚPL/SQL³ÌÐòµÄÉùÃ÷²¿·ÖÏÔʾ¶¨Òå¼Ç¼ÀàÐÍ£»×îºóÒ»ÖÖ·½·¨Êǽ«¼Ç¼ÀàÐͶ¨ÒåΪÊý¾Ý¿â½á¹¹»ò¶ÔÏóÀàÐÍ¡£
ÎÒÏȼòµ¥µÄ½éÉÜÒ»¸öÏÂÃæÒªÓõ½µÄ±íµÄ½á¹¹£¨ºÚÌå±êÃ÷µÄ×Ö¶ÎΪÖ÷¼ü£©£º
INDIVIDUALS±í
 
INDIVIDUAL ID
FIRST NAME
MIDDLE_INITIAL
LAST_NAME
 
ADDRESSES±í
 
ADDRESS ID
INDIVIDUAL ID
STREET_ADDRESS1
STREET_ADDRESS1
STREET_ADDRESS1
CITY
STATE
POSTAL_CODE
COUNTRY_CODE
 
TELEPHONES±í
 
TELEPHONE ID
INDIVIDUAL ID
ADDRESS_ID
TELEPHONE_TYPE
TELEPHONE_NUMBER
 
Ò»¡¢¼Ç¼ÀàÐ͵Ķ¨ÒåºÍʹÓÃ
 
1¡¢Ê¹ÓÃ%ROWTYPEÊôÐÔÒþʽ¶¨Òå¼Ç¼ÀàÐÍ
¿ÉÒÔʹÓÃ%ROWTYPEÊôÐÔÒýÓÃPL/SQLÓαꡢÊý¾Ý¿âÖÐµÄ±í¡¢¶ÔÏó»òÊÓͼ£¬%ROWTYPEÊôÐԼ̳ÐÁËÕâЩ¶ÔÏóµÄÐж¨Òå¡£ÔÚÓÃ%ROWTYPEÊôÐÔ¶¨ÒåµÄÐÐÖУ¬ËùÓÐ×ֶζ¼ÊǸù¾ÝÓëÖ®Ïà¹ØµÄ±íÁеÄÊý¾ÝÀàÐÍÒþʽ¶¨ÒåµÄ¡£×Ö¶ÎÃû³ÆÒ²¾ÍÊDZíÖеÄÁÐÃû¡£
ͨ¹ýʹÓõãÓï·¨¸ô¿ª¼Ç¼±äÁ¿Ãû³ÆºÍ¼Ç¼µÄ×Ö¶ÎÃû£¬ÎÒÃǾͿÉÒÔ·Ö±ð·ÃÎʼǼµÄ¸÷¸ö×ֶΡ£
ÈçÏÂÀýËùʾ£º
DECLARE
-- Define a variable with an implicit record type.
individual individuals%ROWTYPE;
BEGIN
-- Initialize the field values for the record.
individual.individual_id := 1;
individual.first_name := 'John';
individual.middle_initial := 'D';
individual.last_name := 'Rockefeller';
-- Insert the values into the target object.
INSERT
INTO individuals
VALUES
(individual.individual_id
,individual.first_name
,individual.middle_initial
,individual.last_name);
-- Commit the record.
COMMIT;
END;
/   
2¡¢ÏÔʽµØ½«¼Ç¼ÀàÐͶ¨ÒåΪPL/SQL½á¹¹
Ò²¿ÉÒÔÔÚPL/SQL³ÌÐòµÄÉùÃ÷²¿·Ö£¬Í¨¹ý¶¨ÒåÒ»¸ö¼Ç¼ÀàÐ͵ķ½Ê½£¬ÏÔʽµÄ´´½¨Ò»¸ö¼Ç¼ÀàÐÍ¡£¿ÉÒÔÏÔʽµØ¼üÈë±äÁ¿Ãû³ÆÀ´¶¨Òå¼Ç¼ÀàÐ͵ıäÁ¿£¬Ò²¿ÉÒÔʹÓÃ%TYPEÊôÐÔ¶¨Òå±äÁ¿¡£
ÈçÏÂÀýËùʾ£º
DECLARE
-- Define a record type.
TYPE individual_record IS RECORD
(individual_id INTEGER
,first_name VARCHAR2(30 CHAR)
,middle_initial individuals.middle_initial%TYPE
,last_name VARCHAR2(30 CHAR));
-- Define a variable of the record type.
indi


Ïà¹ØÎĵµ£º

Oracle±Ê¼Ç

Oracle µÄ´úÂë±íʾ¼°ÊÂÀý
 
1.  select + xxx + from + xxx   //²éѯÓï¾ä  xxx ±íʾһ¸ö±í  
     Select  *  from  + xxx   // * ±íʾһ¸öÁбíÖÐËùÓеÄÄÚÈÝ
 
  Àࣺ 1£©//  select * from country
 
   ......

OracleµÄ³õʼ»¯²ÎÊýÎļþ

     oracleʵÀýÆô¶¯Ê±¶ÁÈ¡pfile²ÎÊýÎļþ£¬ÐÞ¸Äpfile³õʼ»¯²ÎÊýÎļþºó£¬±ØÐëÖØÐÂÆô¶¯ÊµÀý²ÅÄÜÉúЧ¡£ 
     pfile²ÎÊýÎļþÓëspfile²ÎÊýÎļþ¶¼ÊÇÓÃÀ´´æ·Å³õʼ»¯²ÎÊýµÄÎïÀíÎļþ£¬pfileÒÔÎı¾ÎļþµÄÐÎʽ´æ´¢£¬ÓŵãÊÇÒ×Óڲ鿴ÓëÐ޸ģ»spfileÒÔ¶þ½øÖƵÄÐÎʽ´æ´¢£¬ËäÈ»ÄÜʵÏÖÒÔʵÀ ......

oracle to_date,to_char,trunc,decodeÓ÷¨

select decode('X','Q','±äÁ¿1','±äÁ¿2') from dual
¡¡select sysdate,to_char(sysdate,’yyyy-mm-dd hh24:mi:ss’) from dual
¡¡
¡¡select to_date(’2003-10-17 21:15:37’,’yyyy-mm-dd hh24:mi:ss’) from dual  
ÈÕÆÚ¸ñʽ²ÎÊý º¬Òå˵Ã÷
D Ò»ÖÜÖеÄÐÇÆÚ¼¸
DAY ÌìµÄÃû ......

Oracle³£ÓÃSQLÓï¾ä(PL/SQL developer¹¤¾ßϵÄ)

 ½¨±í
create table users(
id number(4) primary key,
username varchar2(10),
password varchar2(10)
)
²éѯ±í²¢½âËø±í(¼´¿ÉÒÔµã»÷ÊäÈë¿òÏÂÃæµÄ"Ëø"ͼ±ê¹¤¾ß, ¼´"Edit data")
select * from users for update
ɾ³ý±íÖжàÓàµÄÁÐ
alter table mobilephone drop column mobiletype
תÔØ
------------------- ......

SQLÓï¾ä´ó·¨

 SQLÓïÑÔÓÉÃüÁî¡¢×Ӿ䡢ÔËËãºÍ¼¯ºÏº¯ÊýµÈ¹¹³É¡£ÔÚSQLÖУ¬Êý¾Ý¶¨ÒåÓïÑÔDDL£¨ÓÃÀ´½¨Á¢¼°¶¨ÒåÊý¾Ý±í¡¢×Ö¶ÎÒÔ¼°Ë÷ÒýµÈÊý¾Ý¿â½á¹¹£©°üº¬µÄÃüÁîÓÐCREATE¡¢DROP¡¢ALTER£»Êý¾Ý²Ù×ÝÓïÑÔDML£¨ÓÃÀ´ÌṩÊý¾ÝµÄ²éѯ¡¢ÅÅÐòÒÔ¼°É¸Ñ¡Êý¾ÝµÈ¹¦ÄÜ£©°üº¬µÄÃüÁîÓÐSELECT¡¢INSERT¡¢UPDATE¡¢DELETE¡£
Ò»¡¢SQLÓï¾ä
£¨1£©Select ²éѯÓï¾ä
Óï ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ