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