I. mysql entry _ MySQL

Source: Internet
Author: User
I. Getting started with mysql
1 mysql-h localhost-u root-p123456 log on to the mysql Server 2 show databases list all databases 3 use www select a www Database 4 show tables list data tables of the database 5 create table emp (id int auto_increment, name varchar (20), birdate date); create an emp table with the id, name, and birdate fields 6 insert into emp values (null, 'libbin ', '2017-07-06 '); insert a data record 7 insert into emp values (null, 'libbin', '2017-07-06'), (null, 'min ', '2017-07-07 ') insert multiple data entries. 8 update emp set name = 'php' where name = 'Lib '; modify the data of a single field 9 delete from emp where name = 'php'; delete the qualified data 10 alter table emp modify name char (125); modify the attributes of a single field. note: modify cannot modify the field name 11 alter table emp change name cname char (125); modify the attribute of a single field and modify the field name 12 alter table emp modify name char (200) first | after birdate modify the attributes of a single field and specify the modified location 13 alter table emp add column sex tinyint (1) first | add a field after name, you can also specify its location 14 alter table emp delete column sex delete a field 15 describe emp view the structure of a table = desc emp16 show create table emp same as above, but for more details, 17 drop table emp deletes a table 18 select * from emp queries all data in the emp table 19 select name from emp queries only the name field 20 select distinct name from emp queries name non-duplicate data 21 select * from emp where name = 'php '; query data whose name condition is php 22 select * from emp where name = 'php' order by id desc | asc; condition and sort 23 select max (id), min (id ), sum (id) from emp query the maximum, minimum, and total id data 24 select * from emp limit 2 as long as 2 data records 25 select * from emp limit 9, 10 from 10th data records, obtain 10 data records 26 select count (id) from emp, find the total number of data records. 27 select * from emp where id in (select id from emp where name = 'php' or name = 'Lib') subqueries, first, query the id with name php or libin, and then query all data that can match the id through in 28 select. name, B. name from emp as a, emp as B where. id = B. id and. id = 100 inline (table join) 29 select. name, B. name from emp as a left join emp as B on. id = B. id where. id = 100 id 100 left join 30 select. name, B. name from emp as a right join emp as B on. id = B. id where. id = 100 right join 31 32 DCL: 33 grant select, insert on www. * to 'test' @ 'localhost' identified by '000000' create a user test with only the select and insert permissions for all the tables under www. the password is 123456 revoke insert on www. * from 'test' @ 'localhost' revoke test's insert permission 35 36 concat ('Lil', 'bin') string concatenation function, you can directly splice the query result field 37 38 select'
 'Into outfile' c: // qqq. php' text output, which is a dangerous vulnerability 39 select load_file ('C: // qqq. php'); read a text

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.