SQL*PLUSÃüÁî sql±à³ÌÊÖ²á
Ò»¡¢SQL PLUS
1 ÒýÑÔ
SQLÃüÁî
ÒÔÏÂ17¸öÊÇ×÷ΪÓï¾ä¿ªÍ·µÄ¹Ø¼ü×Ö£º
alter drop revoke
audit grant rollback*
commit* insert select
comment lock update
create noaudit validate
delete rename
ÕâЩÃüÁî±ØÐëÒÔ“;”½áβ
´ø*ÃüÁî¾äβ²»±Ø¼Ó·ÖºÅ£¬²¢ÇÒ²»´æÈëSQL»º´æÇø¡£
SQLÖÐûÓеÄSQL*PLUSÃüÁî
ÕâЩÃüÁî²»´æÈëSQL»º´æÇø
@ define pause
# del quit
$ describe remark
/ disconnect run
accept document save
append edit set
break exit show
btitle get spool
change help sqlplus
clear host start
column input timing
compute list ttitle
connect newpage undefine
copy
-------
2 Êý¾Ý¿â²éѯ
Êý¾Ý×Öµä
TAB Óû§´´½¨µÄËùÓлù±í¡¢ÊÓͼºÍͬÒå´ÊÇåµ¥
DTAB ¹¹³ÉÊý¾Ý×ÖµäµÄËùÓбí
COL Óû§´´½¨µÄ»ù±íµÄËùÓÐÁж¨ÒåµÄÇåµ¥
CATALOG Óû§¿É´æÈ¡µÄËùÓлù±íÇåµ¥
select from tab;
describeÃüÁî ÃèÊö»ù±íµÄ½á¹¹ÐÅÏ¢
describe dept
select
from emp;
select empno,ename,job
from emp;
select from dept
order by deptno desc;
Âß¼ÔËËã·û
= !=»ò<> > >= < <=
in
between value1 and value2
like
%
_
in null
not
no in,is not null
ν´ÊinºÍnot in
ÓÐÄÄЩְԱºÍ·ÖÎöÔ±
select ename,job
from emp
where job in ('clerk','analyst');
select ename,job
from emp
where job not in ('clerk','analyst');
ν´ÊbetweenºÍnot between
ÄÄЩ¹ÍÔ±µÄ¹¤×ÊÔÚ2000ºÍ3000Ö®¼ä
select ename,job,sal from emp
where sal between 2000 and 3000;
select ename,job,sal from emp
where sal not between 2000 and 3000;
ν´Êlike,not like
select ename,deptno from emp
where ename like 'S%';
(ÒÔ×ÖĸS¿ªÍ·)
select ename,deptno from emp
where ename like '%K';
(ÒÔK½áβ)
select ename,deptno from emp
where ename like 'W___';
(ÒÔW¿ªÍ·£¬ºóÃæ½öÓÐÈý¸ö×Öĸ)
select ename,job from emp
where job not like 'sales%';
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
Ò»¡¢ÈçºÎ¶¯Ì¬´´½¨Óû§
1.ʹÓô洢¹ý³Ì
sp_addlogin (Transact-SQL)
´´½¨Ð嵀 SQL Server µÇ¼£¬¸ÃµÇ¼ÔÊÐíÓû§Ê¹Óà SQL Server Éí·ÝÑéÖ¤Á¬½Óµ½ SQL Server ʵÀý¡£
ÖØÒªÌáʾ£º
ºóÐø°æ±¾µÄ Microsoft SQL Server ½«É¾³ý¸Ã¹¦ÄÜ¡£Çë±ÜÃâÔÚеĿª·¢¹¤×÷ÖÐʹÓøù¦ÄÜ£¬²¢×ÅÊÖÐ޸ĵ±Ç°»¹ÔÚʹÓøù¦ÄܵÄÓ¦ÓóÌÐò¡£Çë¸ÄÓà CREAT ......
ʹÓÃscott/tigerÓû§ÏµÄemp±íºÍdept±íÍê³ÉÏÂÁÐÁ·Ï°£¬±íµÄ½á¹¹ËµÃ÷ÈçÏÂ
empÔ±¹¤±í(empnoÔ±¹¤ºÅ/enameÔ±¹¤ÐÕÃû/job¹¤×÷/mgrÉϼ¶±àºÅ/hiredateÊܹÍÈÕÆÚ/salн½ð/commÓ¶½ð/deptno²¿ÃűàºÅ)
dept²¿Ãűí(deptno²¿ÃűàºÅ/dname²¿ÃÅÃû³Æ/locµØµã)
¹¤×Ê £½ н½ð £« Ó¶½ð
1£®ÁгöÖÁÉÙÓÐÒ»¸öÔ±¹¤µÄËùÓв¿ÃÅ
2£®Áгöн½ð±È& ......
Ëæ×ÅB/SģʽӦÓÿª·¢µÄ·¢Õ¹£¬Ê¹ÓÃÕâÖÖģʽ±àдӦÓóÌÐòµÄ³ÌÐòÔ±Ò²Ô½À´Ô½¶à¡£µ«ÊÇÓÉÓÚÕâ¸öÐÐÒµµÄÈëÃÅÃż÷²»¸ß£¬³ÌÐòÔ±µÄˮƽ¼°¾ÑéÒ²²Î²î²»Æ룬Ï൱´óÒ»²¿·Ö³ÌÐòÔ±ÔÚ±àд´úÂëµÄʱºò£¬Ã»ÓжÔÓû§ÊäÈëÊý¾ÝµÄºÏ·¨ÐÔ½øÐÐÅжϣ¬Ê¹Ó¦ÓóÌÐò´æÔÚ°²È«Òþ»¼¡£Óû§¿ÉÒÔÌá½»Ò»¶ÎÊý¾Ý¿â²éѯ´úÂ룬¸ù¾Ý³ÌÐò·µ»ØµÄ½á¹û£¬»ñµÃijР......
¿´ÍêÈëÃÅƪºÍ½ø½×ƪºó£¬ÉÔ¼ÓÁ·Ï°£¬ÆƽâÒ»°ãµÄÍøÕ¾ÊÇûÎÊÌâÁË¡£µ«Èç¹ûÅöµ½±íÃûÁÐÃû²Â²»µ½£¬»ò³ÌÐò×÷Õß¹ýÂËÁËһЩÌØÊâ×Ö·û£¬ÔõôÌá¸ß×¢ÈëµÄ³É¹¦ÂÊ£¿ÔõôÑùÌá¸ß²Â½âЧÂÊ£¿Çë´ó¼Ò½Ó×ÅÍùÏ¿´¸ß¼¶Æª¡£
µÚÒ»½Ú¡¢ÀûÓÃϵͳ±í×¢ÈëSQLServerÊý¾Ý¿â
SQLServerÊÇÒ»¸ö¹¦ÄÜÇ¿´óµÄÊý¾Ý¿âϵͳ£¬Óë²Ù×÷ϵͳҲÓнôÃܵÄÁªÏµ£¬Õâ¸ø¿ª·¢ ......