connection class : CopyTable(string,string,bool) method
Description
Duplicates the table.
Syntax
instance.CopyTable(string srcname, string destname, bool withdata)
Arguments
Class | Name | Description |
string | srcname | The source table name. |
string | destname | The destination table name. |
bool | withdata | Whether to copy the data as well. |
Return value
None.
Sample code
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(); |
Notes
Creates and executes an CREATE TABLE statement. In the above sample code, the following SQL statement will be created.
create table new_example_tbl as select * from example_tbl;
If the third argument is false, the following SQL statement will be created.
create table new_example_tbl as select * from example_tbl where 0 > 1;
The data will not be copied because the conditions in the where clause are never met.
Links for reference
None.