HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
SQLite TheCREATE TABLE statement is used in any given database to create a new table.Creating a Basic Table, relates to the data type name tables, columns, and each column definitions.
The basic syntax of CREATE TABLE statement is as follows:
CREATE TABLE database_name.table_name( column1 datatype PRIMARY KEY(one or more columns), column2 datatype, column3 datatype, /en/en. columnN datatype, );
CREATE TABLE tells the system to create a new database table keyword. CREATE TABLE statement is followed by a table name or unique identifier. You can also choose to specifydatabase_namewith thetable_name.
Here is an example, which creates a table COMPANY, ID as the primary key, NOT NULL constraint representation when creating a record in the table, these fields can not be NULL:
sqlite> CREATE TABLE COMPANY ( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (50), SALARY REAL );
Let's create a table, we will be in the next chapter exercises use:
sqlite> CREATE TABLE DEPARTMENT ( ID INT PRIMARY KEY NOT NULL, DEPT CHAR (50) NOT NULL, EMP_ID INT NOT NULL );
You can use the SQLIte command.tables command to verify that the table has been successfully created, the command lists all the additional database tables.
sqlite> .tables COMPANY DEPARTMENT
Here, we can see that we just created two tables COMPANY, DEPARTMENT.
You can useSQLite .schema command to get complete information on the table, as follows:
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 );