Statement/ Command

We communicate with databases through Statements. A Statement are texts that are perceived as a valid command.

It always ends with a semicolon ;

Creating a table

TheCREATE command is used to create a table in the database.

				
					CREATE TABLE 
				
			
Here, CREATE TABLE is a clause. These clauses are usually written in all capital letters.

The basic statement used to create a table is:

				
					CREATE TABLE table_name (
    id INTEGER,
    name TEXT,
    age INTEGER
);
				
			
Let’s break down our statement:
  • table_name refers to the name of the table. Table names are written in a single word. You can use underscore ( _ ) instead of space if you want to include more than one word.
  • The rest of the statement follows the pattern: (column_1 data_type, column_2 data_type, column_3 data_type). So our column number 1 is id with the data type – INTEGER. Basically, it stores the values of data type INTEGER. The rest also follows column name with its associated data type.
  • Statements end with a semicolon

Example

				
					CREATE TABLE jamfinity (
    id INTEGER,
    name TEXT,
    age INTEGER
);
				
			
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments