1. Create a database
Create database test; 2. CREATE TABLE student (id int, name char (8), sex char (4));-Create a student table with ID name sex three field 3. View data table fields select columns from student; show CREATE TABLE student;d Escribe student; Columns where table_name= ' table name '; All of the above methods are available. 4. Insert the data into the insert [into] table name [(column name 1, column name 2, column name 3, ...)] VALUES (value 1, value 2, value 3, ...); The data within [] can omit insert student values (1, ' Luyg ', ' Girl '), insert the specified data into the Insert student (Id,name) VALUES (' Kobe '), 5. Updated Data Update table name set column name = new value where update condition; 6. Delete the data delete from table name where delete condition; Delete from Test where id = 1; 7. Modify the basic form of the table structure: ALTER TABLE name add column list data type [after insertion position]; Example: Append column at the end of the table Address:alter table students add address char (60), insert column after column named Age birthday:alter table students add birthday Date after age;8. Modify column basic form: ALTER TABLE name change column name New Name column new data type; example: Renaming a table Tel column to Telphone:alter table students Change Tel Telphone char (d) Efault "-"; Change the data type of the Name column to char (+): ALTER TABLE students changed name name Char (+) not null;9. Delete Column basic form: ALTER TABLE name DROP column name; ALTER TABLE test drop NAME10. Rename table basic form: ALTER TABLE name rename a new name; 11. Delete Table Basic form: drop database name;
MySQL Basic operation