Recently in the study of MySQL, this article is to do about the MySQL study notes, share with you, hope to learn MySQL knowledge for everyone to help. MySQL is now almost the mainstream database for website construction, and many PHP Web systems use MySQL database. The biggest advantage over MSSQL is open source, free. We hope to make progress together with you.
A simple guide to MySQL Database basics: First enter mysql:mysql-u root-p
1. Build the Library:
Create database name;
For example: Create database MyData; (creating a library called "MyData");
2. Build a table:
Use the name of the library on which to save the table;
CREATE TABLE table name (field set list);
For example: Use MyData; Enter the MyData library
CREATE TABLE MyTable (num VARCHAR), name Varcar (a), birth date,sex CHAR (1)); Create a table named MyTable that contains the school number, name, birthday, and gender.
3. Show all databases:
show databases;
4. Show all tables under a library
Use to query the database name;
Show tables;
5. Delete Tables and libraries:
Delete Library: drop database name;
Delete Table: Name of the drop table;
6. Clear the table record:
Delete from table name;
TRUNCATE TABLE name;
7. Display the records in the table:
SELECT * from table name; * indicates that all records in the table are displayed, or that they can be displayed with different keywords
If there are too many records in the table, only the first few lines can be displayed:
SELECT * from table name limit row number;
For example: SELECT * FROM mytable limit 100; Show the first 100 rows in the MyTable table
8. Rename Table A to B:
ALTER TABLE A rename B;
Other basic can use SQL
Simple operation guide for MySQL database basics