


This example would create a new table called active_employees based on column definitions from both the employees and departments tables. SELECT employees.employee_id AS "active_employee_id",Įmployees.last_name, employees.first_name, partment_name
Create sqlite database using sqlitestudio how to#
Next, let's look at a CREATE TABLE AS example that shows how to create a table by copying selected columns from multiple tables.įor example: CREATE TABLE active_employees AS If there were records in the employees table, then the new active_employees table would be populated with the records returned by the SELECT statement. For example: CREATE TABLE tablename ( column1 datatype constraint, column2 datatype constraint. In the parentheses is the list that defines each column in the table and what kind of data it displays. This example would create a new table called active_employees that included all columns from the employees table. CREATE TABLE is the keyword that tells the database system what you want to do.

Note that you must create the c:\sqlite\db folder first before you execute the. For example, the following Python program creates a new database file pythonsqlite.db in the c:\sqlite\db folder. Let's look at a SQLite CREATE TABLE AS example that shows how to create a table by copying all columns from another table. To create a database, first, you have to create a Connection object that represents the database using the connect () function of the sqlite3 module.
