Follow me. sql: Creating and Modifying tables

Source: Internet
Author: User
Tags command line table name create database

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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.