SQLʹÓü¼ÇÉ
Ò»¡¢¼Ó¿ìsqlµÄÖ´ÐÐËÙ¶È
¡¡¡¡1.select Óï¾äÖÐʹÓÃsort,»òjoin
¡¡¡¡Èç¹ûÄãÓÐÅÅÐòºÍÁ¬½Ó²Ù×÷£¬Äã¿ÉÒÔÏÈselectÊý¾Ýµ½Ò»¸öÁÙʱ±íÖУ¬È»ºóÔÙ¶ÔÁÙʱ±í½øÐд¦Àí¡£ÒòΪÁÙʱ±íÊǽ¨Á¢ÔÚÄÚ´æÖУ¬ËùÒԱȽ¨Á¢ÔÚ´ÅÅÌÉϱí²Ù×÷Òª¿ìµÄ¶à¡£
¡¡¡¡È磺
SELECT time_records.*, case_name¡¡
from time_records, OUTER cases¡¡
WHERE time_records.client = "AA1000"¡¡
AND time_records.case_no = cases.case_no¡¡
ORDER BY time_records.case_no
¡¡¡¡Õâ¸öÓï¾ä·µ»Ø34¸ö¾¹ýÅÅÐòµÄ¼Ç¼£¬»¨·ÑÁË5·ÖÖÓ42Ãë¡£¶ø£º
SELECT time_records.*, case_name¡¡
from time_records, OUTER cases¡¡
WHERE time_records.client = "AA1000"¡¡
AND time_records.case_no = cases.case_no¡¡
INTO temp foo;¡¡
SELECT * from foo ORDER BY case_no¡¡
·µ»Ø34Ìõ¼Ç¼£¬Ö»»¨·ÑÁË59Ãë¡£
¡¡¡¡2.ʹÓÃnot in »òÕßnot exists Óï¾ä
¡¡¡¡ÏÂÃæµÄÓï¾ä¿´ÉÏȥûÓÐÈκÎÎÊÌ⣬µ«ÊÇ¿ÉÄÜÖ´Ðеķdz£Âý£º
SELECT code from table1¡¡
WHERE code NOT IN ( SELECT code from table2
Èç¹ûʹÓÃÏÂÃæµÄ·½·¨£º
SELECT code, 0 flag¡¡
from table1¡¡
INTO TEMP tflag;¡¡
È»ºó£º
UPDATE tflag SET flag = 1
WHERE code IN ( SELECT code¡¡from table2¡¡
WHERE tflag.code = table2.code ;
È»ºó£º
SELECT * from¡¡
tflag¡¡
WHERE flag = 0;
¡¡¡¡¿´ÉÏÈ¥Ò²ÐíÒª»¨·Ñ¸ü³¤µÄʱ¼ä£¬µ«ÊÇÄã»á·¢ÏÖ²»ÊÇÕâÑù¡£
¡¡¡¡ÊÂʵÉÏÕâÖÖ·½Ê½Ð§Âʸü¿ì¡£ÓпÉÄܵÚÒ»ÖÖ·½·¨Ò²»áºÜ¿ì£¬ÄÇÊÇÔÚ¶ÔÏà¹ØµÄÿ¸ö×ֶζ¼½¨Á¢ÁËË÷ÒýµÄÇé¿öÏ£¬µ«ÊÇÄÇÏÔÈ»²»ÊÇÒ»¸öºÃµÄ×¢Òâ¡£
¡¡¡¡3.±ÜÃâʹÓùý¶àµÄ“or"
¡¡¡¡Èç¹ûÓпÉÄܵĻ°£¬¾¡Á¿±ÜÃâ¹ý¶àµØʹÓÃor£º WHERE a = "B" OR a = "C"
¡¡¡¡Òª±È WHERE a IN ("B","C") Âý¡£ ÓÐʱÉõÖÁUNION»á±ÈORÒª¿ì¡£
¡¡¡¡4.ʹÓÃË÷Òý
¡¡¡¡ÔÚËùÓеÄjoinºÍorder by µÄ×Ö¶ÎÉϽ¨Á¢Ë÷Òý¡£ ÔÚwhereÖеĴó¶àÊý×ֶν¨Á¢Ë÷Òý¡£
WHERE datecol >= "this/date" AND datecol
<= "that/date"¡¡Òª±È¡¡WHERE datecol BETWEEN
"this/date" AND "that/date" Âý¡£¡¡¡¡
¡¡¡¡5.ÔÚ·¢Éú´íÎóµÄʱºòÖÕÖ¹sql½Å±¾µÄÖ´ÐÐ
¡¡¡¡Èç¹ûÄã´´½¨ÁËÒ»¸ösql½Å±¾£¬²¢ÇÒÔÚUNIXÃüÁîÐÐÖÐʹÓÃÒÔϵķ½Ê½À´Ö´ÐÐÕâ¸ö½Å±¾£º
¡¡¡¡$ dbaccess <½Å±¾ÎļþÃû>
¡¡¡¡Õâʱ£¬½Å±¾ÖеÄËùÓеÄsqlÓï¾ä¶¼»á±»Ö´ÐУ¬¼´Ê¹ÆäÖеÄÒ»¸ösqlÓï¾ä·¢ÉúÁË´íÎó¡£ÀýÈ磬Èç¹ûÄã½Å±¾ÖÐΪÈçϵÄÓï¾ä£º
BEGIN WORK;¡¡
INSERT INTO history¡¡
SELECT *¡¡
Ïà¹ØÎĵµ£º
×î½üÒ»Ö±ÔÚѧϰSQL serverµÄÄÚÈÝ¡£×òÌ쿼ÁËÒ»ÏÂÊÔ¡£¸Ð¾õÕæµÄÊDz»ÈÝÒ×°¡¡£ÌرðÊÇһЩ¸´ÔӵIJéѯ¡£¸ãµÃÎÒÍ·»èÄÔÕ͵ġ£²»¹ýÒ²ÊÇÓÉÓÚ×Ô¼ºµÄ֪ʶÕÆÎյĻ¹²»¹»Ôúʵ°¡¡£ËùÒÔ½ñÌ츴ϰÁËÒ»ÏÂT-SQlÓï¾äµÄÔöɾ¸Ä²é¡£·¢ÏÖµÄÈ·ÊÇÓкܶ඼Íü¼ÇÁË¡£ÏÖÔڰѽá¹ûд³öÀ´¡£ÒÔºó¿É²»ÒªÍüÁËѽ¡£
--SQLÓï¾ä¸´Ï° --Ò»,²åÈëinsertÓï¾ä --1,ins ......
1 windowsµÇ¼ÕË»§¿Ú£ºEXEC ap_grantlogin 'windowsÓòÃû\ÓòÕË»§'
2 SQL µÇ¼ÕË»§:EXEC sp_addlogin 'ÕË»§Ãû','ÃÜÂë'
3 ´´½¨Êý¾Ý¿âÓû§:exec spgrantdbaccess 'µÇ¼ÕË»§','Êý¾Ý¿âÓû§'
¶þ ¸øÊý¾Ý¿âÓû§ÊÚȨ
grant ȨÏÞ on ±íÃû to Êý¾Ý¿âÓû§ ......
»ùÓÚSQL Server ·ÖÒ³´æ´¢¹ý³ÌµÄÑݽø ÊÕ²Ø
Õë¶ÔÊý¾Ý¿âÊý¾ÝÔÚUI½çÃæÉϵķÖÒ³ÊÇÀÏÉú³£Ì¸µÄÎÊÌâÁË£¬ÍøÉϺÜÈÝÒ×ÕÒµ½¸÷Ö֓ͨÓô洢¹ý³Ì”´úÂ룬¶øÇÒÓÐЩ»¹¶¨ÖƲéѯÌõ¼þ£¬¿´ÉÏȥʹÓúܷ½±ã¡£±ÊÕß´òËãͨ¹ý±¾ÎÄÒ²À´¼òµ¥Ì¸Ò»Ï»ùÓÚSQL SERVER 2000µÄ·ÖÒ³´æ´¢¹ý³Ì£¬Í¬Ê±Ì¸Ì¸SQL SERVER 2005Ï·ÖÒ³´æ´¢¹ý³ÌµÄÑ ......
½«ExcelÎļþÊý¾Ý¿âµ¼ÈëSQL ServerµÄÈýÖÖ·½°¸
//·½°¸Ò»£º ͨ¹ýOleDB·½Ê½»ñÈ¡ExcelÎļþµÄÊý¾Ý£¬È»ºóͨ¹ýDataSetÖÐתµ½SQL Server
openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel files(*.xls)|*.xls";
if(openFileDialog.ShowDialog()==DialogResult.OK)
{
FileInfo ......
Introducing Oracle Database 11g
List the features of Oracle Database 11g
Discuss the basic design, theoretical and physical aspects of a relational database
Categorize the different types of SQL statements
Describe the data set used by the course
Log onto the database using the SQL Develope ......