Again, welcome to the basic series of SQL (Structured Query Language) tutorials. This article describes the instructions that database definition language (DDL) uses to create databases and tables, and to modify the results of a table.
Be careful when you use these instructions-it's easy to delete the main structure in your database so that you lose data. So, before you start modifying the database, you need to know what the database is.
--------------------------------------------------------------------------------
Differences between databases
The sample query system in this article follows the SQL92 ISO standard. Not all databases follow this standard, and some databases are improved, which can produce unpredictable results. If you are unsure whether your database supports the standard, please refer to the documentation.
--------------------------------------------------------------------------------
Creating a Database
To create a table, you first need to create a database that can hold the table. The basic statements that SQL uses to create a database are:
CREATE DATABASE dbname;
Your database users must have the appropriate permissions to establish the database. If the user associated with you cannot issue a command to create a new database, ask the database administrator to set up a database for you, and you can log in as an administrator and set up a database and permissions.
For example, use the Create command to create a database for an application to display a directory:
CREATE DATABASE Catalog;
This gives you a table name that you can use to distinguish it from other tables in the query. The next step is to create a table for entering it.
Create a table
As you know, the form is composed of several columns. When creating a table, you can define columns and assign field properties. After the table is established, you can modify it with the ALTER TABLE instruction, which we will mention later.
You can use the following instruction to create a database, the command line parameter is the table name, column name, and each column data type.
CREATE TABLE table_name
(Column1 data_type, Column2 data_type, Column3 data_type);