ÈçºÎÐÞ¸ÄSQL ServerµÄÁ¬½ÓÊý
ÎÒ°ÑSQL Server 7.0µÄÓû§Á¬½ÓÊýÉèΪ1ºó£¬Êý¾Ý¿â¾ÍÔÙÒ²Á¬²»ÉÏÁË£¬ËùÒÔҲû°ì·¨ÐÞ¸ÄÁ¬½ÓÊý
ÇëÎÊÓÐʲô°ì·¨ÄÜÐÞ¸ÄÁ¬½ÓÊý£¿
ÔÚserver µÄÊôÐÔÀïÃæÓиöconnetctions µÄ
maximun concurrent user connections
Ê×ÏȹرÕËùÓеÄÓû§Á¬½Ó(±ØÒªµÄʱºò²¦µôÍøÏß)
È»ºó´ò¿ªÆóÒµ¹ÜÀíÆ÷--ÓÒ¼üÄãµÄSQLʵÀý--ÊôÐÔ--ÕÒµ½Á¬½Ó,½«Á¬½ÓÓû§Êý¸ÄΪ0
µ«ÊÇÏÖÔÚÊôÐÔ¸ü±¾¾Í´ò²»¿ª
µ¯³ö¾¯¸æ¿ò˵²»ÄÜÕýÈ·Á¬½Ó£¬connection transact(TransactNamedPipe())µÄÁ¬½ÓδȷÁ¢
ÇëÎÊ»¹ÓÐÆäËû·½·¨Â𣿿ɲ»¿ÉÒÔͨ¹ý¸ÄÎļþ»ò×¢²á±íÀ´ÐÞ¸ÄÁ¬½ÓÊý£¿
ÄãµÄ·½·¨ÎÒÊÔ¹ýÁË£¬ÓÒ¼üÄãµÄSQLʵÀý--ÊôÐÔ ÎÞ·¨´ò¿ª
ÄãÊÔÊÔÕâÑù
1.Í£Ö¹sql·þÎñ
2.Óõ¥Óû§Ä£Ê½Æô¶¯SQL
ÔÚÃüÁîÐÐģʽÏÂÊäÈësqlservr -c -f -m»òÕßÊäÈësqlservr -m
......
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢ËµÃ÷£º´´½¨Ð±í
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
¸ù¾ÝÒÑÓÐµÄ±í´´½¨ÐÂ±í£º
A£ºcreate table tab_new like tab_old (ʹÓÃ¾É±í´´½¨Ð±í)
B£ºcreate table tab_new as select col1,col2… from tab_old definition only
5¡¢ËµÃ÷£ºÉ¾³ýбídrop table tabname
6¡¢ËµÃ÷£ºÔö¼ÓÒ»¸öÁÐ
Alter table tabname add column col type
×¢£ºÁÐÔö¼Óºó½«²»ÄÜɾ³ý¡£DB2ÖÐÁмÓÉϺóÊý¾ÝÀàÐÍÒ²²»Äܸı䣬ΨһÄܸıäµÄÊÇÔö¼ÓvarcharÀàÐ͵ij¤¶È¡£
7¡¢ËµÃ÷£ºÌí¼ÓÖ÷¼ü£º Alter tab ......
1.½¨±íÓï¾ä£ºcreate table
Ó÷¨: create table ±íµÄÃû×Ö (×Ö¶Î1, ×Ö¶Î2,¡£¡£¡£¡£)
¾ÙÀý£ºÀýÈç´´½¨Ò»¸öѧÉú³É¼¨±í£¬°üº¬µÄ×Ö¶ÎÓУ¬Ñ§Éúid£¬ÐÕÃû£¬ÐԱ𣬰༶£¬³É¼¨create table score(
create table score(
sid nvarchar(10) primary key,
sname nvarchar(10) not null,
sex nvarchar(2),
sclass nvarchar(5),
score int,
check(sex in('ÄÐ','Å®'))
);
2.²åÈëÓï¾ä£ºinsert into
Ó÷¨:insert into ±íµÄÃû×Ö (×Ö¶Î1, ×Ö¶Î2,¡£¡£¡£¡£) values (Öµ1£¬Öµ2£¬¡£¡£¡£¡£)
Èç¹û×Ö¶ÎÊDZíÖÐËùÓÐ×Ö¶Î×Ö¶ÎÁбí¿ÉÊ¡È¥£¬Ö±½Óд±íÃû¾ÍÐÐÁË
¾ÙÀý:Íù±íscoreÖвåÈë7ÌõÊý¾Ý
insert into score values('95002','СÀî','ÄÐ','01',82)
insert into score values('95003','СÀö','Å®','01',83)
insert into score values('95004','СÕÔ','ÄÐ','01',67)
insert into score values('95005','СÃÀ','Å®','01',78)
insert into score values('95006','СÌï','ÄÐ','01',88)
insert into score values('95007','СÐì','Å®','01',85)
insert into score values('95008','СÍõ','ÄÐ','01',86)
3.²éѯÓï¾ä£ºselect
Ó÷¨£ºselect ×ֶΠfrom ±íà ......
mysqlµ¼ÈësqlÎļþ:Mysqlµ¼Èëµ¼³ö.sqlÎļþ
²½ÖèÈçÏ£º
Ò».MYSQLµÄÃüÁîÐÐģʽµÄÉèÖãº
×ÀÃæ->ÎҵĵçÄÔ->ÊôÐÔ->»·¾³±äÁ¿->н¨->
PATH=“£»path\mysql\bin;”ÆäÖÐpathΪMYSQLµÄ°²×°Â·¾¶¡£
¶þ.¼òµ¥µÄ½éÉÜÒ»ÏÂÃüÁîÐнøÈëMYSQLµÄ·½·¨£º
1.C:\>mysql -h hostname -u username -p
°´ENTER¼ü£¬µÈ´ýÈ»ºóÊäÈëÃÜÂë¡£ÕâÀïhostnameΪ·þÎñÆ÷µÄÃû³Æ£¬Èçlocalhost£¬usernameΪMYSQLµÄÓû§Ãû£¬Èçroot¡£
½øÈëÃüÁîÐкó¿ÉÒÔÖ±½Ó²Ù×÷MYSQLÁË¡£
2.¼òµ¥½éÉÜÒ»ÏÂMYSQLÃüÁ
mysql->CREATE DATABASE dbname;//´´½¨Êý¾Ý¿â
mysql->CREATE TABLE tablename;//´´½¨±í
mysql->SHOW DATABASES;//ÏÔʾÊý¾Ý¿âÐÅÏ¢£¬ÓÐÄÇЩ¿ÉÓõÄÊý¾Ý¿â¡£
mysql->USE dbname;//Ñ¡ÔñÊý¾Ý¿â
mysql->SHOW TABLES;//ÏÔʾ±íÐÅÏ¢£¬ÓÐÄÇЩ¿ÉÓõıí
mysql->DESCRIBE tablename;//ÏÔʾ´´½¨µÄ±íµÄÐÅÏ¢
Èý.´ÓÊý¾Ý¿âµ¼³öÊý¾Ý¿âÎļþ£º
1.½«Êý¾Ý¿âmydbµ¼³öµ½e:\mysql\mydb.sqlÎļþÖУº
´ò¿ª¿ªÊ¼->ÔËÐÐ->ÊäÈëcmd ½øÈëÃüÁîÐÐģʽ
c:\>mysqldump -h localhost -u root -p mydb >e:\mysql\mydb.sql
È»ºóÊäÈëÃÜÂ룬µÈ´ýÒ»»áµ¼³ö¾Í³É¹¦ÁË£¬¿ÉÒÔµ½Ä ......
mysqlµ¼ÈësqlÎļþ:Mysqlµ¼Èëµ¼³ö.sqlÎļþ
²½ÖèÈçÏ£º
Ò».MYSQLµÄÃüÁîÐÐģʽµÄÉèÖãº
×ÀÃæ->ÎҵĵçÄÔ->ÊôÐÔ->»·¾³±äÁ¿->н¨->
PATH=“£»path\mysql\bin;”ÆäÖÐpathΪMYSQLµÄ°²×°Â·¾¶¡£
¶þ.¼òµ¥µÄ½éÉÜÒ»ÏÂÃüÁîÐнøÈëMYSQLµÄ·½·¨£º
1.C:\>mysql -h hostname -u username -p
°´ENTER¼ü£¬µÈ´ýÈ»ºóÊäÈëÃÜÂë¡£ÕâÀïhostnameΪ·þÎñÆ÷µÄÃû³Æ£¬Èçlocalhost£¬usernameΪMYSQLµÄÓû§Ãû£¬Èçroot¡£
½øÈëÃüÁîÐкó¿ÉÒÔÖ±½Ó²Ù×÷MYSQLÁË¡£
2.¼òµ¥½éÉÜÒ»ÏÂMYSQLÃüÁ
mysql->CREATE DATABASE dbname;//´´½¨Êý¾Ý¿â
mysql->CREATE TABLE tablename;//´´½¨±í
mysql->SHOW DATABASES;//ÏÔʾÊý¾Ý¿âÐÅÏ¢£¬ÓÐÄÇЩ¿ÉÓõÄÊý¾Ý¿â¡£
mysql->USE dbname;//Ñ¡ÔñÊý¾Ý¿â
mysql->SHOW TABLES;//ÏÔʾ±íÐÅÏ¢£¬ÓÐÄÇЩ¿ÉÓõıí
mysql->DESCRIBE tablename;//ÏÔʾ´´½¨µÄ±íµÄÐÅÏ¢
Èý.´ÓÊý¾Ý¿âµ¼³öÊý¾Ý¿âÎļþ£º
1.½«Êý¾Ý¿âmydbµ¼³öµ½e:\mysql\mydb.sqlÎļþÖУº
´ò¿ª¿ªÊ¼->ÔËÐÐ->ÊäÈëcmd ½øÈëÃüÁîÐÐģʽ
c:\>mysqldump -h localhost -u root -p mydb >e:\mysql\mydb.sql
È»ºóÊäÈëÃÜÂ룬µÈ´ýÒ»»áµ¼³ö¾Í³É¹¦ÁË£¬¿ÉÒÔµ½Ä ......
ÔÚÓйØÊý¾Ý¿âµÄÏîÄ¿¿ª·¢ÖУ¬±àÂ룬bugÐ޸ĵȵȣ¬¶¼ÐèÒª²é¿´²Ù×÷Ïà¹ØµÄSQLÎÄ£¬Èç¹ûSQLÎıȽϸ´ÔӵĻ°£¬ÎÒÃÇ×Ô¼ºÅÅ°æ·Ç³£Âé·³£¬Í¬Ê±Ò²ºÜ»¨·Ñʱ¼ä¡£¿ÉÄÜÓеĹ«Ë¾×Ô¼º¿ª·¢Á˸ñʽ»¯¹¤¾ß»òÕß¹ºÂòÁ˸ñʽ»¯¹¤¾ßÈí¼þ¡£ÓÐÁ˸ñʽ¹¤¾ßÎÒÃǾͽÚÊ¡ÁËÅÅ°æʱ¼ä¡£
½éÉÜÒ»ÏÂSQLinFormpro_Desktop£¨http://www.sqlinform.com/license.phtml
£©¸ñʽ»¯¹¤¾ß¡£ÓÐÔÚÏß°æºÍ×ÀÃæ°æ¡£×ÀÃæ°æËäȻòËÆÒª»¨Ç®£¬²»¹ýÏÂÔصÄ×ÀÃæ°æ¿ÉÒÔÃâ·ÑʹÓá£ÔÚÍøÒ³µÄDownload & Install Desktop VersionµÄÏÂÃæµã»÷ÏÂÔØ¡£ÓжÔÓ¦JRE1.5£¬JRE1.6µÄÁ½¸ö°æ±¾¡£ÏÂÔغóÎļþÊÇÒÔ.jarΪºó׺µÄÎļþ¡£Ë«»÷Æô¶¯£¬µã»÷×óÉϽǵÄACCEPT°´Å¥¡£¿½±´Òª¸ñʽ»¯µÄSQLÎĵ½±à¼¿òÖУ¬µã»÷Format°´Å¥¾Í¿ÉÒÔ¸ñʽ»¯ÁË¡£
¿ÉÒÔ×Ô¼ºÉèÖøñʽ»¯µÄ¹æÔò£¬Èç»»ÐйæÔò£¬È¥µô¿Õ¸ñ£¬¶ÔÆëµÈµÈ¡£¸ñʽ»¯µÄÀý×ÓÈçͼËùʾ£º
......
ÎÞÂÛÄúÊÇһλ SQL µÄÐÂÊÖ£¬»òÊÇһλֻÊÇÐèÒª¶Ô SQL ¸´Ï°Ò»ÏµÄ×ÊÁϲִ¢Òµ½çÀϽ«£¬Äú¾ÍÀ´¶ÔµØ·½ÁË£¡
- SQL Ö¸Áî: SQL ÈçºÎ±»ÓÃÀ´´¢´æ¡¢¶ÁÈ¡¡¢ÒÔ¼°´¦ÀíÊý¾Ý¿âÖ®ÖеÄ×ÊÁÏ¡£
- ±í¸ñ´¦Àí: SQL ÈçºÎ±»ÓÃÀ´´¦ÀíÊý¾Ý¿âÖеıí¸ñ¡£
- SQLÓï·¨: ÕâÒ»Ò³ÁгöËùÓÐÔÚÕâ¸ö½Ì²ÄÖб»Ìáµ½µÄ SQL Óï·¨
SQL SELECT
Store_Information ±í¸ñ
store_name
Sales
Date
Los Angeles
$1500
Jan-05-1999
San Diego
$250
Jan-07-1999
Los Angeles
$300
Jan-08-1999
Boston
$700
Jan-08-1999
ÈôҪѡ³öËùÓеĵêÃû (store_Name)£¬ÎÒÃǾʹòÈ룺
SELECT store_name from Store_Information
½á¹û:
store_name
Los Angeles
San Diego
Los Angeles
Boston
SQL DISTINCT
ÈôÒªÔÚÒÔϵıí¸ñ£¬Store_Information£¬ÕÒ³öËùÓв»Í¬µÄµêÃûʱ£¬
Store_Information±í¸ñ
store_name
Sales
Date
Los Angeles
$1500
Jan-05-1999
San Diego
$250
Jan-07-1999
Los Angeles
$300
Jan-08-1999
Boston
$700
Jan-08-1999
ÎÒÃǾʹòÈ룬
SELECT DISTINCT store_name from Store_Information
½á¹û:
store_name
Los Angeles
San Diego
Bo ......