SQL ServerÈÕÖ¾Çå³ýµÄÁ½ÖÖ·½·¨
ÔÚʹÓùý³ÌÖдó¼Ò¾³£Åöµ½Êý¾Ý¿âÈÕÖ¾·Ç³£´óµÄÇé¿ö£¬ÔÚÕâÀï½éÉÜÁËÁ½ÖÖ´¦Àí·½·¨……
¡¡¡¡·½·¨Ò»
¡¡¡¡Ò»°ãÇé¿öÏ£¬SQLÊý¾Ý¿âµÄÊÕËõ²¢²»Äܴܺó³Ì¶ÈÉϼõСÊý¾Ý¿â´óС£¬ÆäÖ÷Òª×÷ÓÃÊÇÊÕËõÈÕÖ¾´óС£¬Ó¦µ±¶¨ÆÚ½øÐд˲Ù×÷ÒÔÃâÊý¾Ý¿âÈÕÖ¾¹ý´ó¡£
¡¡¡¡1¡¢ÉèÖÃÊý¾Ý¿âģʽΪ¼òµ¥Ä£Ê½£º´ò¿ªSQLÆóÒµ¹ÜÀíÆ÷£¬ÔÚ¿ØÖÆ̨¸ùĿ¼ÖÐÒÀ´Îµã¿ªMicrosoft SQL Server-->SQL Server×é-->Ë«»÷´ò¿ªÄãµÄ·þÎñÆ÷-->Ë«»÷´ò¿ªÊý¾Ý¿âĿ¼-->Ñ¡ÔñÄãµÄÊý¾Ý¿âÃû³Æ(ÈçÂÛ̳Êý¾Ý¿âForum)-->È»ºóµã»÷ÓÒ¼üÑ¡ÔñÊôÐÔ-->Ñ¡ÔñÑ¡Ïî-->ÔÚ¹ÊÕÏ»¹ÔµÄģʽÖÐÑ¡Ôñ“¼òµ¥”£¬È»ºó°´È·¶¨±£´æ
¡¡¡¡2¡¢ÔÚµ±Ç°Êý¾Ý¿âÉϵãÓÒ¼ü£¬¿´ËùÓÐÈÎÎñÖеÄÊÕËõÊý¾Ý¿â£¬Ò»°ãÀïÃæµÄĬÈÏÉèÖò»Óõ÷Õû£¬Ö±½ÓµãÈ·¶¨
¡¡¡¡3¡¢ÊÕËõÊý¾Ý¿âÍê³Éºó£¬½¨Ò齫ÄúµÄÊý¾Ý¿âÊôÐÔÖØÐÂÉèÖÃΪ±ê׼ģʽ£¬²Ù×÷·½·¨Í¬µÚÒ»µã£¬ÒòΪÈÕÖ¾ÔÚһЩÒì³£Çé¿öÏÂÍùÍùÊǻָ´Êý¾Ý¿âµÄÖØÒªÒÀ¾Ý
¡¡¡¡·½·¨¶þ
¡¡¡¡SET NOCOUNT ON
¡¡¡¡DECLARE @LogicalFileName sysname,
¡¡¡¡@MaxMinutes INT,
¡¡¡¡@NewSize INT
¡¡¡¡USE tablename -- Òª²Ù×÷µÄÊý¾Ý¿âÃû
¡¡¡¡SELECT @LogicalFileName = 'tablename_log', -- ÈÕÖ¾ÎļþÃû
¡¡¡¡@MaxMinutes = 10, -- Limit on time allowed to wrap log.
¡¡¡¡@NewSize = 1 -- ÄãÏëÉ趨µÄÈÕÖ¾ÎļþµÄ´óС(M)
¡¡¡¡-- Setup / initialize
¡¡¡¡DECLARE @OriginalSize int
¡¡¡¡SELECT @OriginalSize = size
¡¡¡¡from sysfiles
¡¡¡¡WHERE name = @LogicalFileName
¡¡¡¡SELECT 'Original Size of ' + db_name() + ' LOG is ' +
¡¡¡¡CONVERT(VARCHAR(30),@OriginalSize) + ' 8K pages or ' +
¡¡¡¡CONVERT(VARCHAR(30),(@OriginalSize*8/1024)) + 'MB'
¡¡¡¡from sysfiles
¡¡¡¡WHERE name = @LogicalFileName
¡¡¡¡CREATE TABLE DummyTrans
¡¡¡¡(DummyColumn char (8000) not null)
¡¡¡¡DECLARE @Counter INT,
¡¡¡¡@StartTime DATETIME,
¡¡¡¡@TruncLog VARCHAR(255)
¡¡¡¡SELECT @StartTime = GETDATE(),
¡¡¡¡@TruncLog = 'BACKUP LOG ' + db_name() + ' WITH TRUNCATE_ONLY'
¡¡¡¡DBCC SHRINKFILE (@LogicalFileName, @NewSize)
¡¡¡¡EXEC (@TruncLog)
¡¡¡¡-- Wrap the log if necessary.
¡¡¡¡WHILE @MaxMinutes > DATEDIFF (mi, @StartTime, GETDATE()) -- time has not expired
¡¡¡¡AND @OriginalSize = (SELECT size from sysfiles
Ïà¹ØÎĵµ£º
1.update a set a.nickname=b.nickname from tab1 a,tab2 b where a.username=b.username
2.Update student_score set
student_score.level=level_about.level from
level_about where student.score
between level_about.start_score and level_about.end_score ......
Maximizing SQL*Loader Performance
SQL*Loader is flexible and offers many options that should be considered to maximize the speed of data loads. These include:
¡ñ Use Direct Path Loads - The conventional path loader essentially loads the data by usin ......
Ó¦ÓÃʾÀý£º
-- ´´½¨2¸ö²âÊÔ±í
CREATE TABLE [dbo].[Table_2019]([Data] [nchar](2019) NOT NULL)
CREATE TABLE [dbo].[Table_2020]([Data] [nchar](2020) NOT NULL)
go
-- Ìî³äÊý¾Ý
declare @i int
set @i = 0
while(@i < 20)
begin
insert Table_2019(Data) values('')
  ......
Óû§×Ô¶¨Ò庯Êý£¨User Defined Functions£©ÊÇSQL Server µÄÊý¾Ý¿â¶ÔÏó£¬Ëü²»ÄÜÓÃÓÚÖ´ÐÐһϵÁиıäÊý¾Ý¿â״̬µÄ²Ù×÷£¬µ«Ëü¿ÉÒÔÏñϵͳº¯ÊýÒ»ÑùÔÚ²éѯ»ò´æ´¢¹ý³ÌµÈµÄ³ÌÐò¶ÎÖÐʹÓã¬Ò²¿ÉÒÔÏñ´æ´¢¹ý³ÌÒ»Ñùͨ¹ý EXECUTE ÃüÁîÀ´Ö´ÐС£Óû§×Ô¶¨Ò庯ÊýÖд洢ÁËÒ»¸öTransact-SQL Àý³Ì£¬¿ÉÒÔ·µ»ØÒ»¶¨µÄÖµ¡£
¡¡¡¡ÔÚSQL Server Öиù¾Ýº ......