Ò»£ºSQL Loader µÄÌصã
oracle×Ô¼º´øÁ˺ܶàµÄ¹¤¾ß¿ÉÒÔÓÃÀ´½øÐÐÊý¾ÝµÄǨÒÆ¡¢±¸·ÝºÍ»Ö¸´µÈ¹¤×÷¡£µ«ÊÇÿ¸ö¹¤¾ß¶¼ÓÐ×Ô¼ºµÄÌص㡣
±ÈÈç˵expºÍimp¿ÉÒÔ¶ÔÊý¾Ý¿âÖеÄÊý¾Ý½øÐе¼³öºÍµ¼³öµÄ¹¤×÷£¬ÊÇÒ»ÖֺܺõÄÊý¾Ý¿â±¸·ÝºÍ»Ö¸´µÄ¹¤¾ß£¬Òò´ËÖ÷ÒªÓÃÔÚÊý¾Ý¿âµÄÈȱ¸·ÝºÍ»Ö¸´·½Ãæ¡£ÓÐ×ÅËٶȿ죬ʹÓüòµ¥£¬¿ì½ÝµÄÓŵ㣻ͬʱҲÓÐһЩȱµã£¬±ÈÈçÔÚ²»Í¬°æ±¾Êý¾Ý¿âÖ®¼äµÄµ¼³ö¡¢µ¼ÈëµÄ¹ý³ÌÖ®ÖУ¬×Ü»á³öÏÖÕâÑù»òÕßÄÇÑùµÄÎÊÌ⣬Õâ¸öÒ²ÐíÊÇoracle¹«Ë¾×Ô¼º²úÆ·µÄ¼æÈÝÐÔµÄÎÊÌâ°É¡£
sql loader ¹¤¾ßȴûÓÐÕâ·½ÃæµÄÎÊÌ⣬Ëü¿ÉÒÔ°ÑһЩÒÔÎı¾¸ñʽ´æ·ÅµÄÊý¾Ý˳ÀûµÄµ¼Èëµ½oracleÊý¾Ý¿âÖУ¬ÊÇÒ»ÖÖÔÚ²»Í¬Êý¾Ý¿âÖ®¼ä½øÐÐÊý¾ÝǨÒƵķdz£·½±ã¶øÇÒͨÓõŤ¾ß¡£È±µã¾ÍËٶȱȽÏÂý£¬ÁíÍâ¶ÔblobµÈÀàÐ͵ÄÊý¾Ý¾ÍÓеãÂé·³ÁË¡£
¶þ. sqlldr °ïÖú£º
C:\Documents and Settings\David>sqlldr
SQL*Loader: Release 10.2.0.1.0 - Production on ÐÇÆÚËÄ 7ÔÂ 2 08:54:06 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Ó÷¨: SQLLDR keyword=value [,keyword=value,...]
ÓÐЧµÄ¹Ø¼ü×Ö:
userid -- ORACLE Óû§Ãû/¿ÚÁî
control -- ¿ØÖÆÎļ ......
Ò»£ºSQL Loader µÄÌصã
oracle×Ô¼º´øÁ˺ܶàµÄ¹¤¾ß¿ÉÒÔÓÃÀ´½øÐÐÊý¾ÝµÄǨÒÆ¡¢±¸·ÝºÍ»Ö¸´µÈ¹¤×÷¡£µ«ÊÇÿ¸ö¹¤¾ß¶¼ÓÐ×Ô¼ºµÄÌص㡣
±ÈÈç˵expºÍimp¿ÉÒÔ¶ÔÊý¾Ý¿âÖеÄÊý¾Ý½øÐе¼³öºÍµ¼³öµÄ¹¤×÷£¬ÊÇÒ»ÖֺܺõÄÊý¾Ý¿â±¸·ÝºÍ»Ö¸´µÄ¹¤¾ß£¬Òò´ËÖ÷ÒªÓÃÔÚÊý¾Ý¿âµÄÈȱ¸·ÝºÍ»Ö¸´·½Ãæ¡£ÓÐ×ÅËٶȿ죬ʹÓüòµ¥£¬¿ì½ÝµÄÓŵ㣻ͬʱҲÓÐһЩȱµã£¬±ÈÈçÔÚ²»Í¬°æ±¾Êý¾Ý¿âÖ®¼äµÄµ¼³ö¡¢µ¼ÈëµÄ¹ý³ÌÖ®ÖУ¬×Ü»á³öÏÖÕâÑù»òÕßÄÇÑùµÄÎÊÌ⣬Õâ¸öÒ²ÐíÊÇoracle¹«Ë¾×Ô¼º²úÆ·µÄ¼æÈÝÐÔµÄÎÊÌâ°É¡£
sql loader ¹¤¾ßȴûÓÐÕâ·½ÃæµÄÎÊÌ⣬Ëü¿ÉÒÔ°ÑһЩÒÔÎı¾¸ñʽ´æ·ÅµÄÊý¾Ý˳ÀûµÄµ¼Èëµ½oracleÊý¾Ý¿âÖУ¬ÊÇÒ»ÖÖÔÚ²»Í¬Êý¾Ý¿âÖ®¼ä½øÐÐÊý¾ÝǨÒƵķdz£·½±ã¶øÇÒͨÓõŤ¾ß¡£È±µã¾ÍËٶȱȽÏÂý£¬ÁíÍâ¶ÔblobµÈÀàÐ͵ÄÊý¾Ý¾ÍÓеãÂé·³ÁË¡£
¶þ. sqlldr °ïÖú£º
C:\Documents and Settings\David>sqlldr
SQL*Loader: Release 10.2.0.1.0 - Production on ÐÇÆÚËÄ 7ÔÂ 2 08:54:06 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Ó÷¨: SQLLDR keyword=value [,keyword=value,...]
ÓÐЧµÄ¹Ø¼ü×Ö:
userid -- ORACLE Óû§Ãû/¿ÚÁî
control -- ¿ØÖÆÎļ ......
select * from student where name=?;
Èç¹û²»Óõ¥ÒýºÅÒýÆðÀ´£¬ pstmt.setString(1,"xx or 1=1");¼´sqlÓ¦¸Ã¾ÍÊÇselect * from student where name=xx or 1=1¾Í¿ÉÒÔÈ«²¿²é³ö¡£
Ç¿ÖƵ¥ÒýºÅÒýÆðÀ´£¬select * from student where name='xx or 1=1'¡£¾ÍÎÞЧÁË¡£
ÊýÖµÐ͵ÄûÓÐÒªÇóÓõ¥ÒýºÅÒýÆðÀ´£¬Ó¦¸ÃÊÇÓÉÓÚÓÐÒ»¸öת»»¹ý³Ì°É¡£
select * from student where id=?;
pstmt.setString(1,"xx or 1=1")ת»»Ê§°Ü¡£pstmt.setInt(1,¾ÍÕâû·¨Ð´ÁË)£» ......
¡¡¡¡1¡¢²é¿´±í¿Õ¼äµÄÃû³Æ¼°´óС
¡¡¡¡select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
¡¡¡¡from dba_tablespaces t, dba_data_files d
¡¡¡¡where t.tablespace_name = d.tablespace_name
¡¡¡¡group by t.tablespace_name;
¡¡¡¡
¡¡¡¡2¡¢²é¿´±í¿Õ¼äÎïÀíÎļþµÄÃû³Æ¼°´óС
¡¡¡¡select tablespace_name, file_id, file_name,
¡¡¡¡round(bytes/(1024*1024),0) total_space
¡¡¡¡from dba_data_files
¡¡¡¡order by tablespace_name;
¡¡¡¡
¡¡¡¡3¡¢²é¿´»Ø¹ö¶ÎÃû³Æ¼°´óС
¡¡¡¡select segment_name, tablespace_name, r.status,
¡¡¡¡(initial_extent/1024) InitialExtent,(next_extent/1024) NextExtent,
¡¡¡¡max_extents, v.curext CurExtent
¡¡¡¡from dba_rollback_segs r, v$rollstat v
¡¡¡¡Where r.segment_id = v.usn(+)
¡¡¡¡order by segment_name ;
¡¡¡¡
¡¡¡¡4¡¢²é¿´¿ØÖÆÎļþ
¡¡¡¡select name from v$controlfile;
¡¡¡¡
¡¡¡¡5¡¢²é¿´ÈÕÖ¾Îļþ
¡¡¡¡select member from v$logfile;
¡¡¡¡
¡¡¡¡6¡¢²é¿´±í¿Õ¼äµÄʹÓÃÇé¿ö
¡¡¡¡select sum(bytes)/(1024*1024) as free_space,tablespace_name
¡¡¡¡from dba_free ......
¡¡¡¡1¡¢²é¿´±í¿Õ¼äµÄÃû³Æ¼°´óС
¡¡¡¡select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
¡¡¡¡from dba_tablespaces t, dba_data_files d
¡¡¡¡where t.tablespace_name = d.tablespace_name
¡¡¡¡group by t.tablespace_name;
¡¡¡¡
¡¡¡¡2¡¢²é¿´±í¿Õ¼äÎïÀíÎļþµÄÃû³Æ¼°´óС
¡¡¡¡select tablespace_name, file_id, file_name,
¡¡¡¡round(bytes/(1024*1024),0) total_space
¡¡¡¡from dba_data_files
¡¡¡¡order by tablespace_name;
¡¡¡¡
¡¡¡¡3¡¢²é¿´»Ø¹ö¶ÎÃû³Æ¼°´óС
¡¡¡¡select segment_name, tablespace_name, r.status,
¡¡¡¡(initial_extent/1024) InitialExtent,(next_extent/1024) NextExtent,
¡¡¡¡max_extents, v.curext CurExtent
¡¡¡¡from dba_rollback_segs r, v$rollstat v
¡¡¡¡Where r.segment_id = v.usn(+)
¡¡¡¡order by segment_name ;
¡¡¡¡
¡¡¡¡4¡¢²é¿´¿ØÖÆÎļþ
¡¡¡¡select name from v$controlfile;
¡¡¡¡
¡¡¡¡5¡¢²é¿´ÈÕÖ¾Îļþ
¡¡¡¡select member from v$logfile;
¡¡¡¡
¡¡¡¡6¡¢²é¿´±í¿Õ¼äµÄʹÓÃÇé¿ö
¡¡¡¡select sum(bytes)/(1024*1024) as free_space,tablespace_name
¡¡¡¡from dba_free ......
Select * into customers from clients
(Êǽ«clients±íÀïµÄ¼Ç¼²åÈëµ½customersÖУ¬ÒªÇó£ºcustomers±í²»´æÔÚ£¬ÒòΪÔÚ²åÈëʱ»á×Ô¶¯´´½¨Ëü£»)
Insert into customers select * from clients
½â£ºInsert into customers select * from clients£©ÒªÇóÄ¿±ê±í£¨customers£©´æÔÚ£¬
ÓÉÓÚÄ¿±ê±íÒѾ´æÔÚ£¬ËùÒÔÎÒÃdzýÁ˲åÈëÔ´±í£¨clients£©µÄ×Ö¶ÎÍ⣬
»¹¿ÉÒÔ²åÈë³£Á¿,ÁíÍâ×¢ÒâÕâ¾äinsert into ºóûÓÐvalues¹Ø¼ü×Ö ......
SQL Server Filtered Indexes - What They Are, How to Use and Performance Advantages
Written By: Arshad Ali -- 7/2/2009 -
Problem
SQL Server 2008 introduces Filtered Indexes which is an index with a WHERE clause. Doesn’t it sound awesome especially for a table that has huge amount of data and you often select only a subset of that data? For example, you have a lot of NULL values in a column and you want to retrieve records with only non-NULL values (in SQL Server 2008, this is called Sparse Column). Or in another scenario you have several categories of data in a particular column, but you often retrieve data only for a particular category value.
In this tip, I am going to walk through what a Filtered Index is, how it differs from other indexes, its usage scenario, its benefits and limitations.
Solution
A Filtered Index, which is an optimized non-clustered index, allows us to define a filter predicate, a WHERE clause, while creating the index. The B-Tree containing rows from ......
ÔÚ±¾ÎÄÖУ¬´ËʾÀý±ê×¼À¶Í¼µÄ´æ´¢¹ý³ÌÃüÃû·½·¨Ö»ÊÊÓÃÓÚSQLÄÚ²¿£¬¼ÙÈçÄãÕýÔÚ´´½¨Ò»¸öеĴ洢¹ý³Ì£¬»òÊÇ·¢ÏÖÒ»¸öûÓа´ÕÕÕâ¸ö±ê×¼¹¹ÔìµÄ´æ´¢¹ý³Ì£¬¼´¿ÉÒԲο¼Ê¹ÓÃÕâ¸ö±ê×¼¡£
×¢ÊÍ£º¼ÙÈç´æ´¢¹ý³ÌÒÔsp_ Ϊǰ׺¿ªÊ¼ÃüÃûÄÇô»áÔËÐеÄÉÔ΢µÄ»ºÂý£¬ÕâÊÇÒòΪSQL Server½«Ê×ÏȲéÕÒϵͳ´æ´¢¹ý³Ì£¬ËùÒÔÎÒÃǾö²»ÍƼöʹÓÃsp_×÷Ϊǰ׺¡£
´æ´¢¹ý³ÌµÄÃüÃûÓÐÕâ¸öµÄÓï·¨£º
[proc] [MainTableName] By [FieldName(optional)] [Action]
[ 1 ] [ 2 ] [ 3 ]¡¡¡¡[ 4 ]
(1) ËùÓеĴ洢¹ý³Ì±ØÐëÓÐǰ׺'proc'. ËùÓеÄϵͳ´æ´¢¹ý³Ì¶¼ÓÐǰ׺"sp_", ÍƼö²»Ê¹ÓÃÕâÑùµÄǰ׺ÒòΪ»áÉÔ΢µÄ¼õÂý¡£
(2) ±íÃû¾ÍÊÇ´æ´¢¹ý³Ì·ÃÎʵĶÔÏó¡£
(3) ¿ÉÑ¡×Ö¶ÎÃû¾ÍÊÇÌõ¼þ×Ӿ䡣 ÀýÈ磺
procClientByCoNameSelect, procClientByClientIDSelect
(4) ×îºóµÄÐÐΪ¶¯´Ê¾ÍÊÇ´æ´¢¹ý³ÌÒªÖ´ÐеÄÈÎÎñ¡£
Èç¹û´æ´¢¹ý³Ì·µ»ØÒ»Ìõ¼Ç¼ÄÇôºó׺ÊÇ£ºSelect
Èç¹û´æ´¢¹ý³Ì²åÈëÊý¾ÝÄÇôºó׺ÊÇ£ºInsert
Èç¹û´æ´¢¹ý³Ì¸üÐÂÊý¾ÝÄÇôºó׺ÊÇ£ºUpdate
Èç¹û´æ´¢¹ý³ÌÓвåÈëºÍ¸üÐÂÄÇôºó׺ÊÇ£ºSave
Èç¹û´æ´¢¹ý³Ìɾ³ýÊý¾ÝÄÇôºó׺ÊÇ£ºDelete
Èç¹û´æ´¢¹ý³Ì¸üбíÖеÄÊý¾Ý (ie. drop and create) ÄÇôºó׺ÊÇ£ºCreat ......