-Create DATABASE Sysdb default Character set utf8;-delete databases drop database sysdb;-view The default character set of the database show create database sysdb;-modify the databases alter SYSDB default character set gbk;#### table management Use Sysdb; Show tables; View all tables//Build data tables CREATE TABLE student (SID int, sname varchar (), sage int); DESC student; View the structure of the Table drop table student; Delete Data table-add field ALTER TABLE student add column Sgender varchar (2); -Delete a field ALTER TABLE student Drop column sgender;-Modify the field type of the sheet ALTER tables student Modify column sname var char (100);-Modify the name of the data table ALTER TABLE student Change Sname (formerly known as) UserName (new name) varchar (20);-Modify table name ALTER TABLE Stu Dent Rename to teacher;## #增加数据-inserting data insert into student values (1, ' CX ', ' man ', 20);-Insert part of the field insert into S Tudent (Id,name) VALUES (2, ' Eric '); # #修改数据-1. Modify a single field update student set gender = "female"//Modify All Update student Set gender = "female" where id = 1; Modify the specified-2. Modify multiple fields update student set gender = ' male ', age = where id = 1;//Tease delimited-3. Delete all data in the table delete from St udent;-4. Remove DELETE from student where id = 2;###### #delete the From and TRUNCATE table differences-delete from can be removed conditionally, tr Uncate table cannot be conditionally deleted-delete from can only delete table data, cannot delete table constraint, truncate can delete table's data or delete table constraint # #查询数据-Query all columns SELECT * F Rom student;-query Specify column select Id,name from student;-query when specifying aliases (multiple table queries, aliases are useful) Select ID as ' number ', name as ' name ' From student s;//s to alias for table-add constant column when querying select ID, Name, gender, age, ' Grade One ' as ' from student; Columns that are added to the query when the column-query merge columns Select ID, name, (score one + Score II) as ' total ' from student merge columns can only merge columns of numeric types-remove duplicate records when querying SEL ECT distinct sex from stuent; Get a man, girl. Two results-conditional query (where)-logical query and, or///query ID 2, student named John Doe SELECT * from S tudent WHERE id = 2 and name = ' John Doe '//Query ID is 2, or name is ZhangThree students select * FROM student where id = 2 and name = ' Zhang San '-Compare conditions > < >= <= <> (not equal) Between and select * from student where JSP between and all SELECT * F Rom student where sex <> ' woman '-empty is null/is not null/= '/<> '//query address empty student SELECT * FROM student where address is null; Judge Null SELECT * FROM student where address = '; Judge Null SELECT * from student where address is null or address = '; Query a student with an address select * from student where address was not null and address <> '; # # # #重点-Fuzzy condition query % = matches n any character//query surname Zhang's student select * from name where name like ' Zhang% '//query surname ' Li ' , and a student with a name of only two characters _ matches an arbitrary character select * from the name where name like ' Li _ '
mysql-(i)