createTableAs

abstract fun createTableAs(table: KQLiteTable, selectStatement: () -> SelectStatement<*>)

Creates a new table and populates it with the result set of a SELECT statement. This is equivalent to the SQL CREATE TABLE ... AS SELECT ... statement. The columns of the new table have the same names and declared types as the columns of the result set from the selectStatement.

Example:

schema.createTableAs(NewUserTable) {
testTable.select(OldUserTable.name).where { id GT 50 AND id.LT(100) }
}

This would create a new table named NewUserTable with a single column name populated with names of users with id greater than 50 and less than 100 from OldUserTable.

Author

MOHAMMAD AZIM ANSARI

Parameters

table

The KQLiteTable object representing the new table to be created.

selectStatement

A lambda function that returns a SelectStatement. The result of this statement will be used to define the structure and initial data of the new table.

See also

Throws

if an error occurs during the creation of the table.