SQL_ѧÉú
µÚ¶þ²¿·Ö
1.ËùÓÐÄÐÉúµÄÐÕÃû¡¢ÄêÁä:
Select Sname£¬Sage
from student;
2.ËùÓÐÄêÁä´óÓÚ20£¬¼ÆËã»ú¿ÆѧϵѧÉúÃûµ¥:
SELECT Sname
from Student
WHERE Sage>20 AND Sdept='CS';
3.³É¼¨´óÓÚ60µÄѧÉúѧºÅ:
SELECT Sno
from SC
WHERE Grade>60;
4.³É¼¨ÔÚ70µ½80Ö®¼äµÄѧÉúѧºÅ:
SELECT Sno
from SC
WHERE Grade>70 AND Grade<80;
SELECT Sno ѧºÅ
from SC
WHERE Grade BETWEEN 70 AND 80;
5.1985µ½1989Äê³öÉúµÄѧÉúÐÕÃû:
SELECT Sname ÐÕÃû
from Student
WHERE 2009-Sage BETWEEN 1985 AND 1989;
SELECT Sname
from Student
WHERE 2009-Sage>1985 AND 2009-Sage<1989;
6.²éѯ³É¼¨²»ÔÚ70µ½85µÄ¼°¸ñѧÉúÃûµ¥:
SELECT DISTINCT Sname
from Student,SC
WHERE Student.Sno=SC.Sno AND Grade NOT BETWEEN 70 AND 80 AND Grade>60;
7.²éѯ³É¼¨ÊÇ70¡¢80¡¢90µÄѧÉúѧºÅ:
SELECT Sno
from SC
WHERE Grade IN(70,80,90);
8.²éѯ1985¡¢1989ÄêµÄѧÉúѧºÅºÍÐÕÃû:
SELECT Sno,Sname
from Student
WHERE 2009-Sage IN('1985','1989');
9.²éѯѧ·Ö²»ÊÇ3¡¢4¡¢5µÄ¿ÎºÅ:
SELECT Cno
from Course
WHERE Ccredit NOT IN(3,4,5);
10.²éѯ2002¼¶ËùÓÐѧÉúÇé¿ö:
SELECT *
from Student
WHERE Sno LIKE '2002%';
SELECT *
from Student
WHERE Sno='2002%';
11.²éѯÐÕÁõ'CS'ϵµÄÐÕÃûºÍÐÔ±ð:
SELECT Sname,Ssex
from Student
WHERE Sdept='CS' AND Sname LIKE 'Áõ%';
12.²éѯÐÕÁõ¡¢ÕÅ¡¢ÀîµÄѧÉúÃûµ¥:
SELECT Sname
from Student
WHERE Sname LIKE '[ÁõÕÅÀî]%';
13.²éѯ¿Î³ÌÃûº¬ÓÐÊý¾ÝµÄ¿Î³ÌÃû³ÆºÍѧ·Ö:
SELECT Cname,Ccredit
from Course
WHERE Cname LIKE '%Êý¾Ý%';
14.²éѯûÓвμӿ¼ÊÔ,¿Î³ÌºÅΪ001µÄѧÉúµÄѧºÅ:
SELECT Sno
from SC
WHERE Cno LIKE '001' AND Grade IS NULL;
15.ËùÓвμÓÁ˿γ̺ÅΪ002µÄѧÉúѧºÅ£¬³É¼¨¡£
SELECT Sno,Grade
from SC
WHERE Cno LIKE '%2';
16.²éѯËùÓÐ2002¼¶ÄÐÉúºÍMAϵµÄѧÉúѧºÅºÍÐÕÃû:
SELECT Sno,Sname
from Student
WHERE Sno LIKE '2002%' AND Ssex LIKE 'ÄÐ' OR Sdept LIKE 'MA';
17.²éѯËùÓÐ4ѧ·ÖºÍÏÈÐпÎΪ6µÄ¿Î³ÌºÅºÍ¿Î³ÌÃû:
SELECT Cno,Cname
from Course
WHERE Ccredit LIKE '4' AND Cpno LIKE '6';
18.²éѯ'CS'ϵѧÉúÃûµ¥,²¢°´ÄêÁä½µÐò,°´ÐÔ±ðÉýÐò:
SELECT Sname,Sage,Ssex
from Student
WHERE Sdept LIKE 'CS'
ORDER BY
Ïà¹ØÎĵµ£º
ת£ºhttp://blog.csdn.net/flyfranker/archive/2009/01/08/3733764.aspx
ASP±à³ÌÃż÷ºÜµÍ£¬ÐÂÊÖºÜÈÝÒ×ÉÏ·¡£ÔÚÒ»¶Î²»³¤µÄʱ¼äÀÐÂÊÖÍùÍù¾ÍÒѾÄܹ»±à³ö¿´À´±È½ÏÍêÃÀµÄ¶¯Ì¬ÍøÕ¾£¬ÔÚ¹¦ÄÜÉÏ£¬ÀÏÊÖÄÜ×öµ½µÄ£¬ÐÂÊÖÒ²Äܹ»×öµ½¡£ÄÇôÐÂÊÖÓëÀÏÊÖ¾ÍûÇø±ðÁËÂð£¿ÕâÀïÃæÇø±ð¿É¾Í´óÁË£¬Ö»²»¹ýÍâÐÐÈ˺ÜÄÑÒ»Ñ۾Ϳ´³öÀ´°ÕÁË¡£ÔÚ½ç ......
update anketo1 set fb = substring('10',fb+1,1) WHERE id =5
ºóÀ´ÎÊÁËBM,BM˵ֱ½ÓÈ¡·´
update anketo1 set fb = ~ fb WHERE id =5
ÎÒ¸æËßÁËBMÓÃsubstringÒ²¿ÉÒÔ.
BM˵:"Õâ¼Ò»ïÀ÷º¦£¬ÕâÒ²ÄÜÏë³ö,ÕâÊôÓÚаÃÅÎ书."
×îºóÓÖÏëµ½ÓÃABSÈ¡¾ø¶ÔÖµÒ²¿ÉÒÔ
update anketo1 set fb = abs(fb-1)
ÎÒ¾õµÃ²»¹ÜÊÇʲôÎ书,ÄÜÖ ......
ÔÚPostgreSQL8.1.3ÉÏ¿ÉÒÔwork
1. È¡Êý¾Ý¿â´óС
SELECT pg_size_pretty(pg_database_size('somedatabase')) As fulldbsize
2. È¡±í´óС
SELECT pg_size_pretty(pg_total_relation_size('someschema.sometable')) As fulltblsize, pg_size_pretty(pg_relation_size('someschema.sometable')) As justthetblsize
ÔÌù£º
......
select case when c.colid=1 then object_name(c.id) else '' end as ±íÃû
,c.name as ×Ö¶ÎÃû
,t.name Êý¾ÝÀàÐÍ
,c.prec as ³¤¶È ......
Èç¹ûÒ»¸ö SQL Óï¾ä·¢ÉúÁË´íÎó£¬ÄÇô sqlca.sqlcode ½«ÊÇ·ÇÁãÖµ¡£
Èç¹û sqlca.sqlcode СÓÚ 0 ÄÇô¾ÍÊÇ·¢ÉúÁËijÖÖÑÏÖصĴíÎó£¬ÏóÊý¾Ý¿â¶¨ÒåÓë²éѯ¶¨Òå²»Ò»Öµȣ®
Èç¹û´óÓÚ 0 ÔòÊÇͨ³£µÄ´íÎó£¬Ïó±í²»°üÀ¨ËùÒªÇóµÄÐеȣ®
sqlca.sqlcode == 0£¬³É¹¦
sqlca.sqlcode == -1 ʧ°Ü £¨»ñÈ¡¾ßÌåʧ°ÜÐÅÏ¢ ......