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

SQLÓï¾ä´óÈ«(1)

--Óï ¾ä ¹¦ ÄÜ
--Êý¾Ý²Ù×÷
SELECT --´ÓÊý¾Ý¿â±íÖмìË÷Êý¾ÝÐкÍÁÐ
INSERT --ÏòÊý¾Ý¿â±íÌí¼ÓÐÂÊý¾ÝÐÐ
DELETE --´ÓÊý¾Ý¿â±íÖÐɾ³ýÊý¾ÝÐÐ
UPDATE --¸üÐÂÊý¾Ý¿â±íÖеÄÊý¾Ý
--Êý¾Ý¶¨Òå
CREATE TABLE --´´½¨Ò»¸öÊý¾Ý¿â±í
DROP TABLE --´ÓÊý¾Ý¿âÖÐɾ³ý±í
ALTER TABLE --ÐÞ¸ÄÊý¾Ý¿â±í½á¹¹
CREATE VIEW --´´½¨Ò»¸öÊÓͼ
DROP VIEW --´ÓÊý¾Ý¿âÖÐɾ³ýÊÓͼ
CREATE INDEX --ΪÊý¾Ý¿â±í´´½¨Ò»¸öË÷Òý
DROP INDEX --´ÓÊý¾Ý¿âÖÐɾ³ýË÷Òý
CREATE PROCEDURE --´´½¨Ò»¸ö´æ´¢¹ý³Ì
DROP PROCEDURE --´ÓÊý¾Ý¿âÖÐɾ³ý´æ´¢¹ý³Ì
CREATE TRIGGER --´´½¨Ò»¸ö´¥·¢Æ÷
DROP TRIGGER --´ÓÊý¾Ý¿âÖÐɾ³ý´¥·¢Æ÷
CREATE SCHEMA --ÏòÊý¾Ý¿âÌí¼ÓÒ»¸öÐÂģʽ
DROP SCHEMA --´ÓÊý¾Ý¿âÖÐɾ³ýÒ»¸öģʽ
CREATE DOMAIN --´´½¨Ò»¸öÊý¾ÝÖµÓò
ALTER DOMAIN --¸Ä±äÓò¶¨Òå
DROP DOMAIN --´ÓÊý¾Ý¿âÖÐɾ³ýÒ»¸öÓò
--Êý¾Ý¿ØÖÆ
GRANT --ÊÚÓèÓû§·ÃÎÊȨÏÞ
DENY --¾Ü¾øÓû§·ÃÎÊ
REVOKE --½â³ýÓû§·ÃÎÊȨÏÞ
--ÊÂÎñ¿ØÖÆ
COMMIT --½áÊøµ±Ç°ÊÂÎñ
ROLLBACK --ÖÐÖ¹µ±Ç°ÊÂÎñ
SET TRANSACTION --¶¨Ò嵱ǰÊÂÎñÊý¾Ý·ÃÎÊÌØÕ÷
--³ÌÐò»¯SQL
DECLARE --Ϊ²éѯÉ趨Óαê
EXPLAN --Ϊ²éѯÃèÊöÊý¾Ý·ÃÎʼƻ®
OPEN --¼ìË÷²éѯ½á¹û´ò¿ªÒ»¸öÓαê
FETCH --¼ìË÷Ò»Ðвéѯ½á¹û
CLOSE --¹Ø±ÕÓαê
PREPARE --Ϊ¶¯Ì¬Ö´ÐÐ×¼±¸SQL Óï¾ä
EXECUTE --¶¯Ì¬µØÖ´ÐÐSQL Óï¾ä
DESCRIBE --ÃèÊö×¼±¸ºÃµÄ²éѯ
---¾Ö²¿±äÁ¿
declare @id char(10)
--set @id = '10010001'
select @id = '10010001'
---È«¾Ö±äÁ¿
---±ØÐëÒÔ@@¿ªÍ·
--IF ELSE
declare @x int @y int @z int
select @x = 1 @y = 2 @z=3
if @x > @y
print 'x > y' --´òÓ¡×Ö·û´®'x > y'
else if @y > @z
print 'y > z'
else print 'z > y'
--CASE
use pangu
update employee
set e_wage =
case
when job_level = ’1’ then e_wage*1.08
when job_level = ’2’ then e_wage*1.07
when job_level = ’3’ then e_wage*1.06
else e_wage*1.05
end
--WHILE CONTINUE BREAK
declare @x int @y int @c int
select @x = 1 @y=1
while @x < 3
begin
print @x --´òÓ¡±äÁ¿x µÄÖµ
while @y < 3
begin
select @c = 100*@x + @y
print @c --´òÓ¡±äÁ¿c µÄÖµ
select @y = @y + 1
end
select @x = @x + 1
select @y = 1
end
--WAITFOR
--Àý µÈ´ý1 Сʱ2 ·ÖÁã3 Ãëºó²ÅÖ´ÐÐS


Ïà¹ØÎĵµ£º

sqlʹÓÃUNION

´´½¨×éºÏ²éѯ
¿ÉÓÃUNION²Ù×÷·ûÀ´×éºÏÊýÌõSQL²éѯ¡£ÀûÓÃUNION£¬¿É¸ø³ö¶àÌõSELECTÓï¾ä£¬½«ËüÃǵĽá¹û×éºÏ³Éµ¥¸ö½á¹û¼¯¡£
16.2.1 ʹÓÃUNION
UNIONµÄʹÓúܼòµ¥¡£ËùÐè×öµÄÖ»ÊǸø³öÿÌõSELECTÓï¾ä£¬ÔÚ¸÷ÌõÓï¾äÖ®¼ä·ÅÉϹؼü×ÖUNION¡£
¾ÙÒ»¸öÀý×Ó£¬¼ÙÈçÐèÒª¼Û¸ñСÓÚµÈÓÚ5µÄËùÓÐÎïÆ·µÄÒ»¸öÁÐ±í£¬¶øÇÒ»¹Ïë°üÀ¨¹©Ó¦ÉÌ1001ºÍ1002É ......

ORACLE SQLÐÔÄÜÓÅ»¯´ó×ܽá

ORACLE SQLÐÔÄÜÓÅ»¯´ó×ܽá
1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
" ?; J) n+ v8 J- v" q    OracleµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡ ......

SQLÓï¾äÓÅ»¯·½·¨30Àý

ÔÚSQLÓï¾äÓÅ»¯¹ý³ÌÖУ¬ÎÒÃǾ­³£»áÓõ½hint,ÏÖ×ܽáÒ»ÏÂÔÚSQLÓÅ»¯¹ý³ÌÖг£¼ûOracle HINTµÄÓ÷¨£º
1. /*+ALL_ROWS*/
±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÍÌÍÂÁ¿,ʹ×ÊÔ´ÏûºÄ×îС»¯.
ÀýÈç:
SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
2. /*+FIRST_ROWS*/
±íÃ÷¶ÔÓï¾ ......

¾«ÃîSQLÓï¾äÕûÀí

Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:mssql7backupMyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack ......

Oracle DBAÊÖ¼ÇÖ®¡°V$SQLÊÓͼÏÔʾ½á¹ûÒì³£µÄÕï¶Ï¡±

±¾ÎĽÚÑ¡×Ô¡¶Oracle DBAÊּǗ—Êý¾Ý¿âÕï¶Ï°¸ÀýÓëÐÔÄÜÓÅ»¯Êµ¼ù¡·µÚ2Õ“YangtingkunµÄDBA¹¤×÷Êּǔ £¨×÷ÕߣºÑîÍ¢çû£©
V$SQLÊÓͼÏÔʾ½á¹ûÒì³£µÄÕï¶Ï
ÓÐÒ»´ÎÅöµ½Ò»¸öºÜÆæ¹ÖµÄÎÊÌ⣬ÔÚ¼ì²é»á»°ËùÖ´ÐеÄSQLʱ£¬·¢ÏÖV$SQLÊÓͼÖÐSQL_TEXTÁÐÖеÄÊý¾ÝÊDz»Õý³£µÄ¡£
ÓÉÓÚV$SQLÊǶ¯Ì¬ÐÔÄÜÊÓͼ£¬ÀïÃæ±£´æµÄÊǵ± ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ