SQLite CREATE TABLE explanation is utilized to make another table in any of the given data set. Making a fundamental table includes naming the table and characterizing its sections and every segment's information type.
Syntax
Following is the essential sentence structure of CREATE TABLE articulation.
CREATE TABLE database_name.table_name(
column1 datatype PRIMARY KEY(one or more columns),
column2 datatype,
column3 datatype,
.....
columnN datatype
);
Make TABLE is the watchword advising the information base framework to make another table. The novel name or identifier for the table follows the CREATE TABLE explanation. Alternatively, you can determine database_name alongside table_name.
Example
Following is a model which makes a COMPANY table with ID as the essential key and NOT NULL are the requirements indicating that these fields can't be NULL while making records in this table.
sqlite> CREATE TABLE COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY REAL
);
Allow us to make one more table, which we will use in our activities in ensuing parts.
sqlite> CREATE TABLE DEPARTMENT(
ID INT PRIMARY KEY NOT NULL,
DEPT CHAR(50) NOT NULL,
EMP_ID INT NOT NULL
);
You can check if your table has been made effectively utilizing SQLite order .tables order, which will be utilized to list down all the tables in a connected data set.
sqlite>.tables
COMPANY DEPARTMENT
Here, you can see the COMPANY table twice since its demonstrating COMPANY table for fundamental information base and test.COMPANY table for 'test' nom de plume made for your testDB.db. You can get total data about a table utilizing the accompanying SQLite .outline order.
sqlite>.schema COMPANY
CREATE TABLE COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY REAL
);