1.MySQl common data types
- int: integer types, such as: age int,
- double: decimal type, such as: score double (5,2), a total of four, two decimal point, such as 99.99
- date: date, containing only the date, yyyy-MM-dd
- datetime: date, time of year, month, day, hour comprising, yyyy-MM-dd HH: mm: ss
timestamp
: Timestamp type, comprising a date when Minutes, yyyy-MM-dd HH: mm: ss
如果将来不给这个类型定义的字段赋值,或者赋值为null,那么会默认使用当前的系统时间来自动赋值
- varchar: string type, for example: name varchar (20), the name field indicates that the maximum 20 characters, "zhangsan" 8 characters, "San" two characters if the character length exceeds a predetermined error will
2. The database table CRUD operations
- C (Create): Creating
1. Create a table:
Create table Table (
Column name Data type 1,
column 2 the data type name,
column name data type 2,
.....
Column Name Data Type n
);
NOTE: The last one without commas
2. Copy table: create table table name like the original table name;
- R (Retrieve): inquiry
1. query a database of all table names: Show the Tables;
2. Query table structure: desc table name;
- U (Update): Modify
1. Modify the table name: alter table table name rename to the new name;
2. modify character set table: alter table table name character set character set name;
3. Add one: alter table table add Column Name Data Type;
4 modify the column name, data type:
- 4.1 change column names and types: alter table change table column names new original column name the new data type;
- . 4.2 modify the data type: alter table column name table modify the new data type;
5. Remove column: alter table drop table column name;
- D (Delete): Delete
Table 1. Delete: drop table name;
presence judgment table 2, there delete: drop table if exists table;
Because the SQL command line input is not so beautiful, and the operation is not convenient, it is recommended to use the graphical interface tools: SQLyog
dolphins than the command line more lovely it! ! ! ! !