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

My PL/SQL practice 8/2/10

SQLPlus  :http://www.orafaq.com/wiki/SQL*Plus_FAQ
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm
1. Transfer values from a sql scripts:
   CNT=`sqlplus -s username/password1@dbname @getUVQuery_NULLCNT`;
 
   Note : Remeber to use option "-s"  (-s or -silent      -- start sqlplus in silent mode. Not recommended for beginners!)
   if not use "-s" , will return something as below :
        SQL*Plus: Release 10.2.0.3.0 - Production on Tue Feb 9 11:03:08 2010
    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    0
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
2.getUVQuery_NULLCNT.sql
        set term off
    column cnt noprint new_value total
    SELECT count(inquiry_id) cnt
      from inquire_all_current a
     WHERE FORM_COMPLETE_STATUS = 'Y'
      and ITEM_POPULATE_STATUS = 'N'
     and expand_type='uvall'
    and uv_query is null
     ORDER BY INQUIRY_ID ASC;
    set term on
    prompt &total
    exit
3. Define cursor and use cursor:
    DECLARE
    CURSOR cur IS
    SELECT inquiry_id
      from inquire_all_current a
     WHERE FORM_COMPLETE


Ïà¹ØÎĵµ£º

SQL Server 2000 Java¿ª·¢Öе±Ç°Èͮ򵀫¦Àí

1¡¢ÔÚÊý¾Ý¿â½¨±íµÄʱºò×Ö¶ÎÖ±½ÓÉèÖÃΪDATETIMEÀàÐÍ£»
2¡¢Ö´ÐвåÈëµÄʱºòʹÓÃÈçÏÂÓï¾ä£º
PreparedStatement pstmt = conn.prepareStatement("insert into guestbook(gst_user,gst_title,gst_content,gst_ip,gst_time) values(?,?,?,?,getdate())");
3¡¢Òª°ÑÈÕÆÚ´ÓÊý¾Ý¿âÖÐÈ¡³ö£¬Ö´ÐÐÈçÏÂÓï¾ä£º
     ......

MS SQL Server2000 ÔÚtomcatϵÄÊý¾ÝÔ´ÅäÖÃ

MS SQL Server2000 Êý¾ÝÔ´ÅäÖÃ
£¨×¢£ºsqljdbc.jarÏÂÔØ²»µ½µÄ»°£¬ÕÒÎÒË÷È¡pengqinghui110@126.com)
1¡¢ÔÚÏîÄ¿µÄWebRootϵÄMETA-INFÖÐн¨context.xmlÎļþ¡£ÄÚÈÝÈçÏ£º
<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Resource name="jdbc/sqlserver"
   &nbs ......

sqlÓï¾ä

select *from student
select student_id from student
select student_id ,student_name from student
select student_id student_name from student  ½«student_name ×÷Ϊstudent_idµÄ±ðÃû´¦Àí
È磺   select student_id a from student
 select a=student_id from student
´Óstudent±íÖзֱð¼ ......

ÄÚÁª SQL PL(Inline SQL PL)

----start
    Í¨³£SQL PLÖ»ÄÜʹÓÃÔÚ´æ´¢¹ý³Ì¡¢´¥·¢Æ÷¡¢Óû§×Ô¶¨Ò庯ÊýÖУ¬µ«ÊÇÓÐÒ»²¿·ÖSQL PLÒ²¿ÉÒÔÖ±½ÓÔÚÃüÁîÐб༭Æ÷»ò½Å±¾ÖÐʹÓã¬ËüÃÇÊÇ£º
DECLARE <variable>
SET
CASE
FOR
GET DIAGNOSTICS
GOTO
IF
RETURN
SIGNAL
WHILE
ITERATE
LEAVE 
ÒÔÏÂSQL PL²»ÄÜÖ±½ÓÔÚÃüÁîÐб༭Æ÷»ò ......

SQL³£Ó÷ÖÒ³µÄ°ì·¨ ת


±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)
1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)
Óï¾äÐÎʽ£º 
SELECT TOP Ò³¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID NOT IN
  (SELECT TOP (ÿҳÐÐÊý*(Ò³Êý-1)) ID
  from ±íÃû
  ORDER BY ID))
  ORDER BY ID
//×Ô¼º»¹¿ÉÒÔ¼ÓÉÏһЩ²é ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ