SQL getting started Tutorial: SQL create table and database [create databse]
The statement for creating a database
The create database statement is used to CREATE a DATABASE.
SQL syntax for creating a database
Create database database_name
The example of creating a database is now that we need to create a database called "my_db ". We use the following create database statement: create database my_db
Next let's take a look at the SQL statement used to create a table
The create table declaration is used to create a table in the database. Create table table_name
(
Column_name1 data_type,
Column_name2 data_type,
Column_name3 data_type,
....
)
The data type specifies the type of data columns that can be shelved. For MS Access, MySQL, and SQL Server provided by a complete reference for all data types, please give us a complete data type reference. Now we want to create a table named "person", which contains five columns: P_Id, last name, name, address, and city. Create table Persons
(
P_Id int,
LastName varchar (255 ),
FirstName varchar (255 ),
Address varchar (255 ),
City varchar (255)
)
The P_Id column is of the int type and is held some. The maximum length of the last name, name, address, and city column varchar is 255 characters. The blank "person" looks like this: _ Id LastName FirstName Address City