Mysql 4: SQL statement 2

Source: Internet
Author: User

Create a database:

CREATE DATABASE stefan;

Delete database:

DROP DATABASE stefan;

Rename a database:

There is no direct way to rename the database.

Methods that are no longer used:

RENAME DATABASE stefan TO LCDB;

Create Table Syntax:

Create table Name (column name 1 data type, column name 2 data type, column name 3 data type ,....)

View the structure of a table:

DESCRIBE Persons;

The alter table statement is used to add, modify, or delete columns in an existing TABLE.

Syntax:

To add columns to a table, use the following syntax:

ALTER TABLE table_nameADD column_name datatype

To delete columns in a table, use the following syntax:

ALTER TABLE table_name DROP COLUMN column_name

Note: Some database systems do not allow this method of deleting columns in database tables (drop column column_name ).

To change the data type of columns in a table, use the following syntax:

ALTER TABLE table_nameALTER COLUMN column_name datatype

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.