ID int identity(1,1) primary key ×Ô¶¯Ôö³¤,Ö÷¼ü
EXEC sp_rename 'login_info','PDI_login_info' Ö´Ðд洢¹ý³Ì sp_rename , ½«login_info±íÃû ¸ü¸ÄΪ PDI_login_info
SET XACT_ABORT {ON|OFF} Èç¹ûÊÂÎñÖз¢Éú´íÎó£¬on Ôò»áÖÕÖ¹Õû¸öÊÂÎñµÄÖ´ÐУ¬Èç¹ûOFF£¬¼ÌÐø´íÎóµÄÏÂÃæÒ»¾ä
SET ANSI_NULLS {ON|OFF} ÓÃÓÚºÍNULLµÄ±È½Ï£¬È磺null=nullÔÚoffʱ»á·µ»Ø true,ÔÚon ʱΪfalse
set QUOTED_IDENTIFIER ON Ϊ ON ʱ£¬±êʶ·û¿ÉÒÔÓÉË«ÒýºÅ»òÕß[]·Ö¸ô£¬¶øÎÄ×Ö±ØÐëÓɵ¥ÒýºÅ·Ö¸ô,Ϊ OFF ʱ£¬±êʶ·û²»¿É¼ÓÒýºÅ£¬ÇÒ±ØÐë·ûºÏËùÓÐ Transact-SQL ±êʶ·û¹æÔò
SET NOCOUNT {ON| OFF} µ±SET NOCOUNT Ϊ ON ʱ£¬²»·µ»Ø¼ÆÊý£¨±íʾÊÜ Transact-SQL Óï¾äÓ°ÏìµÄÐÐÊý£©¡£µ± SET NOCOUNT Ϊ OFF ʱ£¬·µ»Ø¼ÆÊý ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssql
Óï¾ä£¬²»¿ÉÒÔÔÚaccess
ÖÐʹÓá£
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 a ......
index.jsp
<%@ page language="java" import="java.sql.*" import="java.lang.*" import="java.util.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%!
int CountPage = 0;
int CurrPage = 1;
int PageSize = 5;
int CountRow = 0;
public Connection Con() {
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection Con = DriverManager.getConnection("jdbc:mysql://localhost:3306/userdb?user=root&password=zhz&useUnicode=true&characterEncoding=gb2312");
&nb ......
index.jsp
<%@ page language="java" import="java.sql.*" import="java.lang.*" import="java.util.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%!
int CountPage = 0;
int CurrPage = 1;
int PageSize = 5;
int CountRow = 0;
public Connection Con() {
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection Con = DriverManager.getConnection("jdbc:mysql://localhost:3306/userdb?user=root&password=zhz&useUnicode=true&characterEncoding=gb2312");
&nb ......
character-set-server = GB2312
collation-server = latin1_general_ci
MySQL×Ö·û¼¯ GBK¡¢GB2312¡¢UTF8Çø±ð ½â¾ö MYSQLÖÐÎÄÂÒÂëÎÊÌâ ÊÕ²Ø
MySQLÖÐÉæ¼°µÄ¼¸¸ö×Ö·û¼¯
character-set-server/default-character-set£º·þÎñÆ÷×Ö·û¼¯£¬Ä¬ÈÏÇé¿öÏÂËù²ÉÓõġ£
character-set-database£ºÊý¾Ý¿â×Ö·û¼¯¡£
character-set-table£ºÊý¾Ý¿â±í×Ö·û¼¯¡£
ÓÅÏȼ¶ÒÀ´ÎÔö¼Ó¡£ËùÒÔÒ»°ãÇé¿öÏÂÖ»ÐèÒªÉèÖÃcharacter-set-server£¬¶øÔÚ´´½¨Êý¾Ý¿âºÍ±íʱ²»ÌرðÖ¸¶¨×Ö·û¼¯£¬ÕâÑùͳһ²ÉÓÃcharacter-set-server×Ö·û¼¯¡£
character-set-client£º¿Í»§¶ËµÄ×Ö·û¼¯¡£¿Í»§¶ËĬÈÏ×Ö·û¼¯¡£µ±¿Í»§¶ËÏò·þÎñÆ÷·¢ËÍÇëÇóʱ£¬ÇëÇóÒÔ¸Ã×Ö·û¼¯½øÐбàÂë¡£
character-set-results£º½á¹û×Ö·û¼¯¡£·þÎñÆ÷Ïò¿Í»§¶Ë·µ»Ø½á¹û»òÕßÐÅϢʱ£¬½á¹ûÒÔ¸Ã×Ö·û¼¯½øÐбàÂë¡£
ÔÚ¿Í»§¶Ë£¬Èç¹ûûÓж¨Òåcharacter-set-results£¬Ôò²ÉÓÃcharacter-set-client×Ö·û¼¯×÷ΪĬÈϵÄ×Ö·û¼¯¡£ËùÒÔÖ»ÐèÒªÉèÖÃcharacter-set-client×Ö·û¼¯¡£
Òª´¦ÀíÖÐÎÄ£¬Ôò¿ÉÒÔ½«character-set-serverºÍcharacter-set-client¾ùÉèÖÃΪGB2312£¬Èç¹ûҪͬʱ´¦Àí¶à¹úÓïÑÔ£¬ÔòÉèÖÃΪUTF8¡£
¹ØÓÚMySQLµÄÖÐÎÄÎÊÌâ
½â¾öÂÒÂëµÄ·½·¨ÊÇ£¬ÔÚÖ´ÐÐSQLÓï¾ä֮ǰ£¬½«MySQLÒÔÏÂÈý¸öϵͳ²Î ......
character-set-server = GB2312
collation-server = latin1_general_ci
MySQL×Ö·û¼¯ GBK¡¢GB2312¡¢UTF8Çø±ð ½â¾ö MYSQLÖÐÎÄÂÒÂëÎÊÌâ ÊÕ²Ø
MySQLÖÐÉæ¼°µÄ¼¸¸ö×Ö·û¼¯
character-set-server/default-character-set£º·þÎñÆ÷×Ö·û¼¯£¬Ä¬ÈÏÇé¿öÏÂËù²ÉÓõġ£
character-set-database£ºÊý¾Ý¿â×Ö·û¼¯¡£
character-set-table£ºÊý¾Ý¿â±í×Ö·û¼¯¡£
ÓÅÏȼ¶ÒÀ´ÎÔö¼Ó¡£ËùÒÔÒ»°ãÇé¿öÏÂÖ»ÐèÒªÉèÖÃcharacter-set-server£¬¶øÔÚ´´½¨Êý¾Ý¿âºÍ±íʱ²»ÌرðÖ¸¶¨×Ö·û¼¯£¬ÕâÑùͳһ²ÉÓÃcharacter-set-server×Ö·û¼¯¡£
character-set-client£º¿Í»§¶ËµÄ×Ö·û¼¯¡£¿Í»§¶ËĬÈÏ×Ö·û¼¯¡£µ±¿Í»§¶ËÏò·þÎñÆ÷·¢ËÍÇëÇóʱ£¬ÇëÇóÒÔ¸Ã×Ö·û¼¯½øÐбàÂë¡£
character-set-results£º½á¹û×Ö·û¼¯¡£·þÎñÆ÷Ïò¿Í»§¶Ë·µ»Ø½á¹û»òÕßÐÅϢʱ£¬½á¹ûÒÔ¸Ã×Ö·û¼¯½øÐбàÂë¡£
ÔÚ¿Í»§¶Ë£¬Èç¹ûûÓж¨Òåcharacter-set-results£¬Ôò²ÉÓÃcharacter-set-client×Ö·û¼¯×÷ΪĬÈϵÄ×Ö·û¼¯¡£ËùÒÔÖ»ÐèÒªÉèÖÃcharacter-set-client×Ö·û¼¯¡£
Òª´¦ÀíÖÐÎÄ£¬Ôò¿ÉÒÔ½«character-set-serverºÍcharacter-set-client¾ùÉèÖÃΪGB2312£¬Èç¹ûҪͬʱ´¦Àí¶à¹úÓïÑÔ£¬ÔòÉèÖÃΪUTF8¡£
¹ØÓÚMySQLµÄÖÐÎÄÎÊÌâ
½â¾öÂÒÂëµÄ·½·¨ÊÇ£¬ÔÚÖ´ÐÐSQLÓï¾ä֮ǰ£¬½«MySQLÒÔÏÂÈý¸öϵͳ²Î ......
Sql´úÂë
--²ÉÓÃSQLÓï¾äʵÏÖsql2005ºÍExcel Êý¾ÝÖ®¼äµÄÊý¾Ýµ¼Èëµ¼³ö£¬ÔÚÍøÉÏÕÒÀ´Ò»--Ï£¬ÊµÏÖ·½·¨ÊÇÕâÑùµÄ£º
--Excel---->SQL2005 µ¼È룺
select * into useinfo from OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 5.0;HDR=YES;DATABASE=d:\db.xls',sheet1$);
--ÆäÖУ¬useinfo ÊÇÊý¾Ý¿âÖеÄÒ»¸ö±í£¬d:\db.xls ΪÊý¾ÝÔ´£¬ÖµµÃÌá³öµÄÊÇ£º--sheet1$£¬¼ÇµÃ¼ÓÉÏ$¡£
---SQL2005--->Excel µ¼³ö£º
insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 5.0;HDR=YES;DATABASE=d:\test.xls',sheet1$) select * from useinfo;
--н¨Ò»¸ötest.xml Îļþ£¬ÆäÖÐtest.xmlµÄsheet1 µÄ±íÍ·± ......
Sql´úÂë
--²ÉÓÃSQLÓï¾äʵÏÖsql2005ºÍExcel Êý¾ÝÖ®¼äµÄÊý¾Ýµ¼Èëµ¼³ö£¬ÔÚÍøÉÏÕÒÀ´Ò»--Ï£¬ÊµÏÖ·½·¨ÊÇÕâÑùµÄ£º
--Excel---->SQL2005 µ¼È룺
select * into useinfo from OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 5.0;HDR=YES;DATABASE=d:\db.xls',sheet1$);
--ÆäÖУ¬useinfo ÊÇÊý¾Ý¿âÖеÄÒ»¸ö±í£¬d:\db.xls ΪÊý¾ÝÔ´£¬ÖµµÃÌá³öµÄÊÇ£º--sheet1$£¬¼ÇµÃ¼ÓÉÏ$¡£
---SQL2005--->Excel µ¼³ö£º
insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 5.0;HDR=YES;DATABASE=d:\test.xls',sheet1$) select * from useinfo;
--н¨Ò»¸ötest.xml Îļþ£¬ÆäÖÐtest.xmlµÄsheet1 µÄ±íÍ·± ......
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Data£¨µ¼ÈëÊý¾Ý£©¡£
¡¡¡¡¡ð3ÔÚChoose a Data Source£¨Ñ¡ÔñÊý¾ÝÔ´£©¶Ô»°¿òÖÐÑ¡ÔñMicrosoft Access as the Source£¬È»ºó¼üÈëÄãµÄ.mdbÊý¾Ý¿â(.mdbÎļþÀ©Õ¹Ãû)µÄÎļþÃû»òͨ¹ýä¯ÀÀÑ°ÕÒ¸ÃÎļþ¡£
¡¡¡¡¡ð4ÔÚChoose a Destination£¨Ñ¡ÔñÄ¿±ê£©¶Ô»°¿òÖУ¬Ñ¡ÔñMicrosoft OLE¡¡DB Prov ider for SQL¡¡Server£¬Ñ¡ÔñÊý¾Ý¿â·þÎñÆ÷£¬È»ºóµ¥»÷±ØÒªµÄÑéÖ¤·½Ê½¡£
¡¡¡¡¡ð5ÔÚSpecify Table Copy£¨Ö¸¶¨±í¸ñ¸´ÖÆ£©»òQuery£¨²éѯ£©¶Ô»°¿òÖУ¬µ¥»÷Copy tables£¨¸´ÖƱí¸ñ£©¡£
¡ð6ÔÚSelect Source Tables£¨Ñ¡ÔñÔ´±í¸ñ£©¶Ô»°¿òÖУ¬µ¥»÷Select All£¨È«²¿Ñ¡¶¨£©¡£ÏÂÒ»²½£¬Íê³É¡£
Transact-SQLÓï¾ä½øÐе¼Èëµ¼³ö£º
1.ÔÚSQL SERVERÀï²éѯaccessÊý¾ ......
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Data£¨µ¼ÈëÊý¾Ý£©¡£
¡¡¡¡¡ð3ÔÚChoose a Data Source£¨Ñ¡ÔñÊý¾ÝÔ´£©¶Ô»°¿òÖÐÑ¡ÔñMicrosoft Access as the Source£¬È»ºó¼üÈëÄãµÄ.mdbÊý¾Ý¿â(.mdbÎļþÀ©Õ¹Ãû)µÄÎļþÃû»òͨ¹ýä¯ÀÀÑ°ÕÒ¸ÃÎļþ¡£
¡¡¡¡¡ð4ÔÚChoose a Destination£¨Ñ¡ÔñÄ¿±ê£©¶Ô»°¿òÖУ¬Ñ¡ÔñMicrosoft OLE¡¡DB Prov ider for SQL¡¡Server£¬Ñ¡ÔñÊý¾Ý¿â·þÎñÆ÷£¬È»ºóµ¥»÷±ØÒªµÄÑéÖ¤·½Ê½¡£
¡¡¡¡¡ð5ÔÚSpecify Table Copy£¨Ö¸¶¨±í¸ñ¸´ÖÆ£©»òQuery£¨²éѯ£©¶Ô»°¿òÖУ¬µ¥»÷Copy tables£¨¸´ÖƱí¸ñ£©¡£
¡ð6ÔÚSelect Source Tables£¨Ñ¡ÔñÔ´±í¸ñ£©¶Ô»°¿òÖУ¬µ¥»÷Select All£¨È«²¿Ñ¡¶¨£©¡£ÏÂÒ»²½£¬Íê³É¡£
Transact-SQLÓï¾ä½øÐе¼Èëµ¼³ö£º
1.ÔÚSQL SERVERÀï²éѯaccessÊý¾ ......