Basic mysql operations in Windows and basic windowsmysql
1. Database Table operations:
- -Start the mysql server, 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 (10), room varchar (10) charset utf8; --> show tables like "% s "; -->
- Query the table creation statement: show create table my_student; --> omit the colon statement: show create table my_student \ g --> another output format:
- Show create table my_student \ G
- -Rename the 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 a field: it is usually an attribute or data type. --> alter table name mondify field name data type [attribute] [location]; --> alter table my_student modify number char (10) after id;
- -Rename field: alter table name change old field new field data type [attribute] [location];
- Alter table my_student change gender sex varchar (10) after id;
- -Delete field: Delete the age field (age) in the student table --> alter table my_student drop age;
- -- Delete a data table: drop table 1, 2, 3... --> drop table class;
2. Data Operations
- Insert into my_student values (1, '001', 'J', 'jin'), (2. '002', 'h', 'huni ');
- Insert into my_student (number, name, sex, id) values ('003 ', 'jeny', 'male', 3), ('004', 'the shy ', 'femal', 4 );
- View data: select */Field List from table name [where condition]; --> select * from my_student; --> select id, number, sex, name from my_student where id = 1;
- Update Data: update table name set field = value [where condition];
- Delete data: delete form table name [where condition];