mysql-database and data table structure and operation

Source: Internet
Author: User

1. Database system: A database system is a system tool for maintaining and managing databases, and the database system has its own user name and password

1.1. Display the database in the system:show databases;

1.2. Creating database: Create databases;

1.3. Delete a database in the system:drop Database name

Table 2.MySql: In MySQL relational database, the table is the most basic unit, in each data table mainly consists of the following parts: Table name, list, column data type, column constraints.

The actions for a table are as follows:

2.1. Creation of data tables:

  create table table name ([ integrity constraints         Property name data type [ integrity constraints ,
       :
        attribute name data table [ Integrity constraints
 );

  2.2. Data type: Data type in the previous section, it is not verbose again.

  2.3. Column constraint:

2.3.1. PRIMARY key: PRIMARY KEY constraint

2.3.2.foreign key: FOREIGN KEY constraint

     2.3.3. not null: null constraint, the column field cannot be empty

     2.3.4. unique: Unique constraint that indicates that the field value is unique

     2.3.5. Auto_increment: Self-growing,

     2.3.6.default: Default value

3. View the structure of the table:

 3.1. describe (DESC): View the structure of the table

 3.2. show CREATE table: View the structure of the table, including the SQL statement

4. Modify the structure of a table

 4.1. Modify table name:  alter table old table name renmae new table name

 4.2. Add column field:  alter table table name add 1 data type [ integrity constraints ] [First | After 2]---First: Indicates that the data is inserted in the top row of the table, After  property name   2: Insert data after a row

 4.3. Modify column fields:  alter table table name change old property name new property name new data type

 4.4. Delete Column: alter Table drop property name

5. Delete table: delete table drop table table name

 

Note: The above content is only to provide a way of learning, in the actual development of the proposed use of image interface, directly on the above operation, greatly improve the efficiency.

mysql-database and data table structure and operation

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.