SQL SERVER 2008Êý¾Ý¿â¸½¼Ó
2008Êý¾Ý¿â¸½¼Ó
/*
ÍøÉÏ¿´µ½µÄÕûÀíÁËһϡ£
ÔÎĵØÖ·http://database.51cto.com/art/201003/190984.htm
ÔÚSQL Server 7.0ÖУ¬Î¢ÈíÍƳöÁËsp_attach_dbºÍsp_attach_single_file_dbϵͳ´æ´¢¹ý³Ì¡£
Ëü¶ÔÓÚSQL ServerÊý¾Ý¿â¹ÜÀíÔ±Ö´ÐÐÏÂÃæµÄÈÎÎñÊǷdz£·½±ãµÄ£º
1 ʹÓÃsp_attach_dbϵͳ´æ´¢¹ý³ÌÖ±½Ó½«.MDFºÍ.LDFÎļþ¸½¼Óµ½·þÎñÆ÷¡£
2 ʹÓÃsp_attach_single_file_dbϵͳ´æ´¢¹ý³ÌÖ»¸½¼Ó.MDFÎļþ¡£
3 ʹÓÃsp_detach_db½«Êý¾Ý¿â´ÓÒ»¸ö·þÎñÆ÷·ÖÀ룬¸´ÖÆ.MDFÎļþµ½ÁíÒ»¸ö·þÎñÆ÷ÉÏ£¬È»ºóʹÓÃ
sp_attach_dbϵͳ´æ´¢¹ý³ÌÖØи½¼ÓÕâЩÎļþµ½Á½¸ö·þÎñÆ÷ÉÏ¡£
¾¡¹ÜËü¶ÔÓÚSQL ServerÊý¾Ý¿â¹ÜÀíÔ±ÊǺÜÓÐÓõģ¬µ«ÊÇÔÚʹÓÃÕâÁ½¸ö´æ´¢¹ý³ÌʱÊÇÓÐһЩÏÞÖƵġ£ÏÞÖÆÈçÏ£º
1 Äã²»Äܸ½¼Ó¶à¸öÈÕÖ¾Îļþ
2 Äã²»Äܸ½¼Ó¸öÒÔÉϵÄÎļþ
ÔÚSQL Server 2008ÖУ¬Î¢ÈíÐû²¼ÉÏÃæµÄϵͳ´æ´¢¹ý³Ì½«ÔÚδÀ´µÄ°æ±¾Öб»·ÏÆú¡£¶øËûÃÇÔÚ"Create Database"
SQLÓï¾äÖÐÌí¼ÓÁËÒ»¸ö´Ó¾ä"For Attach"¡£
ÏÂÃæ½éÉÜʹÓÃ"For Attach"´Ó¾äµÄ¶àÖÖ·½·¨£¬ÒÔ¿Ë·þÔÚʹÓÃsp_attach_dbºÍsp_attach_single_file_dbʱҪÃæÁÙµÄÏÞÖÆ¡£
*/
--½¨Á¢²âÊÔÊý¾Ý¿â
Use Master
go
CREATE DATABASE TestDB
ON
( NAME = TestDB,
FILENAME = 'D:\TestDB.mdf',
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = TestDB_log,
FILENAME = 'D:\TestDB_log.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
--ÏÖÔÚ£¬ÈÃÎÒÃÇ·ÖÀë¸ÃÊý¾Ý¿â£¬²¢³¢ÊÔʹÓÃsp_detach_dbºÍsp_attach_db½«ËüÖØи½¼Ó¡£
--Ö´ÐÐÏÂÃæµÄÊÂÎñSQLÓï¾ä¡£
use master
go
sp_detach_db 'TestDB'
go
sp_attach_db 'TestDB',
'D:\TestDB.mdf',
'D:\TestDB_log.ldf'
GO
--ÄãÒ²¿ÉÒÔʹÓþßÓÐ"For Attach"´Ó¾äµÄ"Create database
Ïà¹ØÎĵµ£º
select *
from (
select soft.NETMODEL,
soft.softname,
soft.softid ......
1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
¡¡¡¡2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
¡¡¡¡3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£
¡¡¡¡4¡¢ÄÚ´æ²»×ã
¡¡¡¡5¡¢ÍøÂçËÙ¶ÈÂý
¡¡¡¡6¡¢²éѯ³öµÄÊý¾ÝÁ¿¹ý´ó(¿ÉÒÔ²ÉÓöà´Î²éѯ£¬ÆäËûµÄ·½·¨½µµÍÊý¾ÝÁ¿)
¡¡¡¡7¡¢Ëø»òÕßËÀËø(ÕâÒ²ÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐ ......
1.ɾ³ý±í
select 'drop table ' || table_name || ' purge;'
from user_tables
where length(table_name) <= 4;
ɾ³ý´øÔ¼ÊøµÄ±í
Drop table ±íÃû cascade constraints;
2.²éѯview&ͬÒå´Ê
--˵Ã÷£º¿ÉÒÔ¸ù¾ÝÊÓͼµÄtext_length ......
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
impo ......