connection クラス : CopyTable(string,string,bool)メソッド
説明
テーブルを複製します。
構文
instance.CopyTable(string srcname, string destname, bool withdata)
引数
| クラス | 名前 | 説明 |
| string | srcname | コピー元テーブルの名前。 |
| string | destname | コピー先テーブルの名前。 |
| bool | withdata | データもコピーするかどうかを示す値。 |
返り値
無し。
サンプルコード
| 1: | connection cnn = new connection("Data Source=c:\somedirectory\somedatabase.sqlite3;Version=3;"); |
| 2: | cnn.Open(); |
| 3: | dictionary{string} ds; |
| 4: | ds.Add("ids","integer"); |
| 5: | ds.Add("textdata","text"); |
| 6: | // create table example_tbl(ids integer, textdata text); |
| 7: | cnn.CreateTable("example_tbl", ds); |
| 8: | // create table new_example_tbl as select * from example_tbl; |
| 9: | cnn.CopyTable("example_tbl", "new_example_tbl", true); |
| 10: | cnn.Close(); |
| 11: | cnn.Release(); |
注意
CREATE TABLE文を作成して実行します。上記のサンプルコードならば以下のSQL文が作成されます。
create table new_example_tbl as select * from example_tbl;
第三引数が false だった場合は、以下のSQL文が作成されます。
create table new_example_tbl as select * from example_tbl where 0 > 1;
where 節の条件が成立しないのでデータはコピーされません。
参照リンク
無し。


