1. Database table operations:
- -Start the MySQL server first, open the CMD window in the directory where MySQL is installed, and run MySQL: ' mysql.exe-hlocalhost-p3306-uroot-p123456 ';
- -View all databases: show databases; --Create DATABASE my_database;
- -Use my_database; --Show tables; --Create TABLE class (name varchar), guest charset UTF8; --Show tables like '%s '; -
- Create statement for query table: Show CREATE TABLE my_student; --Omit the colon notation: show create TABLE My_student\g--and another output format:
- Show CREATE TABLE My_student\g
- -Rename table: Rename table student to my_student;
- -View the table structure of the data table: DESC table name; -->describe table name; --Show columns from table name;
- -Add a new field to the table: ALTER TABLE my_student add column ID int first/after;
- -Modify field: Modify is usually a property or data type;--> ALTER TABLE name mondify field name data type [properties] [location]; --ALTER TABLE my_student Modify number char (ten) after ID;
- -Rename field: ALTER TABLE name change old field new field data type [property] [position];
- ALTER TABLE my_student change gender sex varchar (TEN) after ID;
- -delete field: Delete The Age field in the Student's table (ages)---ALTER TABLE my_student drop;
- - Delete Data sheet: drop table ... -Drop table class;
Basic operations for MySQL under Windows