Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : sql

oracle³£ÓõÄsqlÃüÁî

Êý¾Ý¶¨ÒåÓïÑÔ£¨DDL£©<²Ù×÷±íµÄ½á¹¹>£ºcreate£¨ ´´½¨£©¡¢
alter£¨¸ü¸Ä£©¡¢
drop£¨É¾³ý£©
Êý¾Ý²Ù×ÝÓïÑÔ£¨DML£©<²Ù×÷±íµÄÊý¾Ý>£ºinsert£¨²åÈ룩¡¢select£¨Ñ¡Ôñ£©¡¢delete£¨É¾³ý£©¡¢update£¨¸üУ©
ÊÂÎñ¿ØÖÆÓïÑÔ£¨TCL£©£ºcommit £¨ Ìá½»£©¡¢savepoint£¨±£´æµã£©¡¢rollback£¨»Ø¹ö£©
Êý¾Ý¿ØÖÆÓïÑÔ£ºgrant£¨ÊÚÓ裩ºÍrevoke£¨»ØÊÕ£©¡£ÓëȨÏÞÓйØ
¾ÙÀý£º
1¡¢Êý¾Ý¶¨ÒåÓïÑÔDDL
SQL> create table myTable(no number(4),name varchar2(20)); // ´´½¨Ò»¸öÃûΪmyTableµÄ±í£¬°üº¬Á½ÁзֱðΪno ºÍname£¬ÆäÖÐnoΪÊý×Ö£¬nameΪ×Ö·û´®
SQL> alter table myTable modify (name varchar2(25)); //ÐÞ¸ÄmyTableÖеÄname ÁУ¬Ê¹´ËÁÐÄÜÈÝÄÉ25 ¸ö×Ö·û£»
SQL> alter table myTable add (tel_no varchar2(20)); //¸ø±ímyTab Ôö¼ÓÒ»ÁÐtel_no£»
SQL> alter table myTable drop column tel_no; //ɾ³ý±ímyTab µÄtel_no ÁÐ;
SQL> drop table myTable; //ɾ³ý±ímyTable£»
SQL> truncate table myTable; //ɾ³ý±ímyTableÖеÄËùÓÐÐУ¨½Ø¶Ï±í£©,×¢Òâ:´Ë²Ù×÷²»¿ÉÒÔrollback(»Ø¹ö)¡£
2¡¢Êý¾Ý²Ù×ÝÓïÑÔDML
SQL> insert into myTable values(‘001’,’ ......

oracle³£ÓõÄsqlÃüÁî

Êý¾Ý¶¨ÒåÓïÑÔ£¨DDL£©<²Ù×÷±íµÄ½á¹¹>£ºcreate£¨ ´´½¨£©¡¢
alter£¨¸ü¸Ä£©¡¢
drop£¨É¾³ý£©
Êý¾Ý²Ù×ÝÓïÑÔ£¨DML£©<²Ù×÷±íµÄÊý¾Ý>£ºinsert£¨²åÈ룩¡¢select£¨Ñ¡Ôñ£©¡¢delete£¨É¾³ý£©¡¢update£¨¸üУ©
ÊÂÎñ¿ØÖÆÓïÑÔ£¨TCL£©£ºcommit £¨ Ìá½»£©¡¢savepoint£¨±£´æµã£©¡¢rollback£¨»Ø¹ö£©
Êý¾Ý¿ØÖÆÓïÑÔ£ºgrant£¨ÊÚÓ裩ºÍrevoke£¨»ØÊÕ£©¡£ÓëȨÏÞÓйØ
¾ÙÀý£º
1¡¢Êý¾Ý¶¨ÒåÓïÑÔDDL
SQL> create table myTable(no number(4),name varchar2(20)); // ´´½¨Ò»¸öÃûΪmyTableµÄ±í£¬°üº¬Á½ÁзֱðΪno ºÍname£¬ÆäÖÐnoΪÊý×Ö£¬nameΪ×Ö·û´®
SQL> alter table myTable modify (name varchar2(25)); //ÐÞ¸ÄmyTableÖеÄname ÁУ¬Ê¹´ËÁÐÄÜÈÝÄÉ25 ¸ö×Ö·û£»
SQL> alter table myTable add (tel_no varchar2(20)); //¸ø±ímyTab Ôö¼ÓÒ»ÁÐtel_no£»
SQL> alter table myTable drop column tel_no; //ɾ³ý±ímyTab µÄtel_no ÁÐ;
SQL> drop table myTable; //ɾ³ý±ímyTable£»
SQL> truncate table myTable; //ɾ³ý±ímyTableÖеÄËùÓÐÐУ¨½Ø¶Ï±í£©,×¢Òâ:´Ë²Ù×÷²»¿ÉÒÔrollback(»Ø¹ö)¡£
2¡¢Êý¾Ý²Ù×ÝÓïÑÔDML
SQL> insert into myTable values(‘001’,’ ......

SQLÓï·¨×ܽá

ÕâÊÇÎÒ±ßѧ±ß×ܽáµÄ£¬×ܹ²»¨ÁËÒ»ÌìÒ»Ò¹µÄʱ¼ä£¬²é×ÊÁϺͿ´ÊÓƵÍê³ÉµÄ£¬µ«ÎÒ¶Ôµ¥Ðк¯ÊýºÍ¶àÐк¯ÊýûÓÐ×ö¹ý¶àµÄÑо¿£¬ÒòΪÕß¿ÉÒÔ²éÎĵµ¡£»¹ÓоÍÊǶà±í²éѯÑо¿Ò²±È½Ïdz£¬Õâ¿ÉÒÔÔÚÒÔºóÓõ½µÄʱºòÔÚ¾ßÌåÑо¿¡£   »¹ÓоÍÊÇÒªÊìϤÊý¾Ý¿âµÄ²Ù×÷£¬Ôöɾ¸Ä²é£¬ÕâЩ¶¼ÒªÏ൱ÊìÁ·£¬Íü¼ÇʱҪ¼°Ê±¿´±Ê¼Ç¡£
SQL
1.......Êý¾ÝÀàÐÍ
char(10)£¨Õâ¸öÊÇÓÃÀ´´æ´¢Ö¸¶¨´æ´¢´óСµÄ×Ö·û¿ª±ÙµÄ¿Õ¼äΪ10£©,
varchar2(10)£¨Õâ¸öÊÇÓÃÀ´´æ´¢×Ö·û£¬¿ª±ÙµÄ¿Õ¼äΪ10µ±´æ´¢µÄ×Ö·û¿Õ¼ä²»µ½10ʱ¶àÓàµÄ¿Õ¼ä×Ô¶¯Êջأ¬ÖÐÎÄÕ¾Á½¸ö¿Õ¼ä£©,number(10)£¨ÓÃÀ´´æ´¢ÕûÊý£©,number(10,3)£¨ÓÃÀ´´æ´¢Ð¡Êý£¬Ò»¹²10λСÊýÕ¼Èý룩,date£¨ÓÃÀ´´æ´¢ÈÕÆÚ£©¡£
2.......´´½¨±í
Àý£º
create table fg_user
( name char(10),
age number(3),
salary number(7,2),
birthday date
);
fg_userÊDZíÃû£¨fgÊÇǰ׺£©¡£
3.......²éѯ±í
desc fg_userÊDzéѯ±íµÄ£¨¿´¿´´´½¨ÁËÄÇЩÀàÈÝÈ磺name£¬age£¬salary£¬birthdayµÈ£©¡£
4.......Ïò±íÖÐдÈëÊý¾Ý£ºinsert into fg_user values('·ë¿¡','19','-700',','11-7ÔÂ-1990');
µ±ÓеÄÊý¾Ý²»È·¶¨Ê±¿ÉÒÔÓúóÃæÁ½ÖÖд·¨ÖеÄÒ»ÖÖ£º
insert into fg_user values('·ë¿¡',19,- ......

ÁøÓÀ·¨³£ÓÃSQLÓï¾ä±¸Íü

--------------------------Êý¾Ý¿â²Ù×÷--------------------------  
--½¨Êý¾Ý¿â  
create database yongfa365_com  
on 
( name = yongfa365_comt,  
  filename = 'd:\yongfa365_com.mdf',  
  size = 4,  
  maxsize = 10,  
  filegrowth = 1  
)  
 
 
--ɾÊý¾Ý¿â  
drop database yongfa365_com  
 
--±¸·ÝÊý¾Ý¿â  
backup database yongfa365_com to disk='d:\yongfa365_com.bak' 
 
--ÅúÁ¿ÊÕËõËùÓÐÊý¾Ý¿â  
declare cur cursor for select name from Master..SysDatabases where name not in ('master','model','msdb','Northwind','pubs')  
declare @tb sysname   
 
open cur   
fetch next from cur into @tb   
while @@fetch_status=0   
begin   
 exec ('dump transaction ['+@tb+'] with no_log') &nb ......

Á¬½ÓSQL server2005Êý¾Ý¿â¶Ë1433¶Ë¿ÚµÄÕýÈ··½·¨¡£

½ñÌì×°ÁËSQL server2005Êý¾Ý¿â£¬Íê³ÉºóÁ¬½Ó¶Ë¿Ú1433ʱʧ°ÜÁË£¬µÚÒ»´Î°²×°µÄʱºò£¬Ã»ÓаѻúÆ÷ÖеÄSQL server2000Êý¾Ý¿âжÔصô£¬È»ºóжÔØ—>°²×°—>Á¬½Ó,»¹ÊÇʧ°Ü¡£ÓÚÊÇÏÂÃæ¾Í¿ªÊ¼ÅŲ顢µ÷ÊÔÒÔ¼°ÖØ×°SQL server2005Êý¾Ý¿â³ÌÐò£¬ÕûÁË¿ìÒ»Ì죬ÖÕÓÚÔÚÏ°àµÄʱºòÁ¬½Ó³É¹¦¡£
    ÏÖÔÚ°ÑÔÚ×°Íê³ÌÐòºó£¬Á¬½Ó¶Ë¿Ú1433Ç°£¬Òª×öµÄ¼¸¼þÊÂÇéºÍ×¢ÒâÊÂÏî×ܽáһϡ£
²½Ö裺
1.¹Ø±ÕÊý¾Ý¿âÒýÇæ,¹Ø±ÕÊý¾Ý¿âÒýÇæÓÐÈýÖÖ·½·¨£º
    (1)¿ªÊ¼->³ÌÐò->Microsoft SQL Server 2005->ÅäÖù¤¾ß->SQL Server 2005ÍâΧӦÓÃÅäÖÃÆ÷,ÔÚ´ò¿ªµÄ½çÃæµ¥»÷"·þÎñµÄÁ¬½ÓµÄÍâΧӦÓÃÅäÖÃÆ÷",ÔÚ´ò¿ªµÄ½çÃæÖÐÕÒµ½Database Engine,µ¥»÷"·þÎñ",ÔÚÓÒ²à²é¿´ÊÇ·ñÒÑÆô¶¯,Èç¹ûÒÑÆô¶¯¿Éµ¥»÷“Í£Ö¹”°´Å¥£¬¼´¿É¹Ø±ÕÊý¾Ý¿âÒýÇæ¡£
(2)¿ªÊ¼->³ÌÐò->Microsoft SQL Server 2005->ÅäÖù¤¾ß->SQL Server Configuration Manager,Ñ¡ÖÐSQL Server 2005·þÎñÖÐSQL Server(MSSQLSERVER) ,²¢Ñ¡ÖÐÓÒ»÷,µã»÷Í£Ö¹£¬ ¼´¿É¹Ø±ÕÊý¾Ý¿âÒýÇæ¡£
(3) ¿ªÊ¼->³ÌÐò->Microsoft SQL Server 2005-> SQL Server Management Studio£¬ÔÚµ¯³öµÄÁ¬½ÓÊý¾Ý¿âÒýÇæ¶Ô»°¿òÖе ......

ºÃ³¤µÄSQL£¡

select a.FRMNO,a.GATE,a.MSGID,a.MailSendTime,a.UserNM, a.MailSubject,a.IsRead,a.FRMID,a.isattach,b.STATE ,a.FLOWSTATE from   ROAMSGE a, ROASTAT b where a.FRMID = b.FRMID and b.state='1'  and a.FrmNm like '%" + Cdorpsel1 + "%' and a.MAILSENDTIME>to_date('" + date1 + "','YYYY-MM-DD') and a.MAILSENDTIME<=to_date('" + date2 + "','YYYY-MM-DD')+1 and a.ToUserId='" + flw_LogonId + "' order by MAILSENDTIME desc ......

oracle sql×Ô¶¯µÝÔö

Ò»¡¢É¾³ýÁÐ
ALTER TABLE AA DROP COLUMN  DEP;
ÊÊÓÃÓÚС±í-----Êý¾ÝÁ¿Ð¡µÄʱºò£»
2¡¢ALTER TABLE AA SET UNUSED("DEP") CASCADE CONSTRAINTS;
È»ºóÔÚ¸ºÔØСµÄʱºò£¬É¾³ý
ALTER TABLE AA DROP UNUSED COLUMNS;
¶þ¡¢Ìí¼ÓÁÐ
ÏȼÓÒ»ÐÂ×Ö¶ÎÔÙ¸³Öµ£º
alter table table_name add mmm  varchar2(10);
update table_name set mmm=** ;
Èý¡¢ÉèÖÃ×Ö¶ÎÖµ×Ô¶¯Ôö¼Ó
insert into t_address (addressname) (select vcname from busstop)
create sequence seq_id_test_increment    --ÐòÁÐ
increment by 1 start with 1 maxvalue 9999999;   
  
create or replace trigger insert_test_increment    --´¥·¢Æ÷
before insert on t_address    --t_address    ±í
referencing   
new as new   
old as old   
for each row   
begin  
    select seq_id_test_increment.nextval into :new.addressid from dual;    --addressid×Ö¶Î
end; ......

oracle sql×Ô¶¯µÝÔö

Ò»¡¢É¾³ýÁÐ
ALTER TABLE AA DROP COLUMN  DEP;
ÊÊÓÃÓÚС±í-----Êý¾ÝÁ¿Ð¡µÄʱºò£»
2¡¢ALTER TABLE AA SET UNUSED("DEP") CASCADE CONSTRAINTS;
È»ºóÔÚ¸ºÔØСµÄʱºò£¬É¾³ý
ALTER TABLE AA DROP UNUSED COLUMNS;
¶þ¡¢Ìí¼ÓÁÐ
ÏȼÓÒ»ÐÂ×Ö¶ÎÔÙ¸³Öµ£º
alter table table_name add mmm  varchar2(10);
update table_name set mmm=** ;
Èý¡¢ÉèÖÃ×Ö¶ÎÖµ×Ô¶¯Ôö¼Ó
insert into t_address (addressname) (select vcname from busstop)
create sequence seq_id_test_increment    --ÐòÁÐ
increment by 1 start with 1 maxvalue 9999999;   
  
create or replace trigger insert_test_increment    --´¥·¢Æ÷
before insert on t_address    --t_address    ±í
referencing   
new as new   
old as old   
for each row   
begin  
    select seq_id_test_increment.nextval into :new.addressid from dual;    --addressid×Ö¶Î
end; ......
×ܼǼÊý:4346; ×ÜÒ³Êý:725; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [679] [680] [681] [682] 683 [684] [685] [686] [687] [688]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ