One, the database connection
* Connect Database command (if you need to install MYSQ):
Mysql-h Hostip-u Username-ppassword
Second, the database operation
* View all databases:
show databases;
* Select Database
Use DatabaseName;
* CREATE Database
Create Database DatabaseName;
* Delete Database
Drop DatabaseName;
Third, table operation
* View the table of the current database
Show tables;
* Create a table
CREATE TABLE TableName (columnName1 type constraint,columnName2 type constraint,..Unique (columnName)) Data type:Integer, size that specifies the maximum number of digits of the value;Decimal (size,d) accommodates numbers with decimals;numberic (size,d) size, the maximum number of digits, the maximum number of digits to the right of the D decimal;char (size) fixed-length string;varchar (size) accommodates a variable-length string of the maximum length of the size string;CONSTRAINTSN constraints:NOT NULL constraint forcing column is not nullUnique constraint uniquely identifies each record in a database table (ALTER table tableName add unique (columnName))primary key Primary KEY, the constraint uniquely identifies each record in the database table, cannot be empty (null), and each table has only one primary key;foreign key points to primary key in another table (ALTER table tableName1 ADD foreign (columnName) REFERENCES tableName2 (columnName ))A check constraint is used to limit the range of values in a column;The default constraint is used to insert defaults in the column
Iv. Data manipulation (find, add, delete, update)
* Query statement Select column_name from tblename where columnName operator value; * operator:=,<>,>,<,>=,<=,between,like; * Sort order BY (DESC,ASC) SELECT * from TableName order by ColumnName ASC; * Insert a statement INSERT INTO TableName (columnname1,columnname2 ...) VALUES (value1,value2 ...); * Updated statement update tableName Set columnName = newvalue where columnName = value; * DELETE statement Delete from tableName where columnName = value;
-------temporarily updated here-------
a random recommendation: A class of PHP MySQL that has been packaged on GitHub click here to view
MySQL Database------Operations Command notes