星期二, 9月 29, 2009

[MSSQL] 如何做partition switch在不同的兩個table.

這是說明
http://msdn.microsoft.com/zh-tw/library/ms191174.aspx
這是例子
http://technet.microsoft.com/zh-tw/library/bb964715.aspx

這些link在講解partition table如何把partition switch到另外一個table。
參考一下吧。

星期一, 9月 07, 2009

[MSSQL] bcp 使用與根據input date format import

http://technet.microsoft.com/en-us/library/ms162802.aspx
這是MSDN的bcp說明
http://technet.microsoft.com/en-us/library/ms191516.aspx
這是怎麼create format file
http://technet.microsoft.com/en-us/library/ms189327.aspx
這是xml schema syntax
http://technet.microsoft.com/en-us/library/ms190919.aspx
http://technet.microsoft.com/en-us/library/ms179250.aspx
http://technet.microsoft.com/en-us/library/ms191175.aspx
這幾個是應用,看你要是Using a Format File to Skip a Table Column
Using a Format File to Skip a Data Field
Using a Format File to Map Table Columns to Data-File Fields
都好用~~~~

星期二, 9月 01, 2009

[SQL] insert into on duplicate update

在MySQL有一個超好用的語法:
insert into table_name values(...) on duplicate key update column_name = ...

可是在其他的Database裡就沒有,例如MSSQL(SQL server 200x), PostgreSQL, Oracle
所以就Google了一下,發現一個超好用的方式,就是用stored procedure解
下面是link
http://aiplab.net/forum/index.php?topic=698.0
http://blogs.msdn.com/miah/archive/2008/02/17/sql-if-exists-update-else-insert.aspx

CREAT PROCEDURE insert_update
@value1,
@value2,
@value3...
AS
BEGIN TRANSACTION

UPDATE Table1 SET (...) WHERE Column1='SomeValue'
IF @@ROWCOUNT=0
INSERT INTO Table1 VALUES (...)

COMMIT TRANSACTION
GO

只要程式call stored procedure就非常美好嚕~~~~^_________^

星期五, 8月 21, 2009

[MySQL] how to use mysqldump.

--opt

This option is shorthand; it is the same as specifying --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset. It should give you a fast dump operation and produce a dump file that can be reloaded into a MySQL server quickly.

The --opt option is enabled by default. Use --skip-opt to disable it. See the discussion at the beginning of this section for information about selectively enabling or disabling certain of the options affected by --opt.

1. Backup要下的指令是
mysqldump --add-drop-table --add-locks --create-options --disable-keys --extended-insert --single-transaction --quick --set-charset --user=username --password db_name [db_tables] > dumpfile.sql

2. restore要下的指令是
Edit the dumpfile.sql and put these lines at the beginning:

SET AUTOCOMMIT = 0;
SET FOREIGN_KEY_CHECKS=0;

Put these lines at the end:

SET FOREIGN_KEY_CHECKS = 1;
COMMIT;
SET AUTOCOMMIT = 1;

mysql --user=username --password db_name < dumpfile.sql

星期一, 6月 15, 2009

[Perl] perl的dbi教學

這個網站對於perl的dbi有詳細的介紹,有需要的人可以參考一下。

http://perl.hcchien.org/ch15.html
http://www.felixgers.de/teaching/perl/perl_DBI.html