Home > Database > Mysql Tutorial > body text

一、mysql使用入门_MySQL

WBOY
Release: 2016-05-31 08:47:23
Original
1080 people have browsed it
 1 mysql -h localhost -u root -p123456 登录mysql服务器 2 show databases 列出所拥有的数据库 3 use www 选择一个www的数据库 4 show tables 列出该库的数据表 5 create table emp (id int auto_increment,name varchar(20),birdate date); 创建一个emp表,有id,name,birdate三个字段 6 insert into emp values(null,'Libin','2014-07-06'); 插入一条数据 7 insert into emp values(null,'Libin','2014-07-06'),(null,'Min','2014-07-07') 插入多条数据 8 update emp set name = 'Php' where name = 'Libin'; 修改单个字段数据 9 delete from emp where name = 'Php'; 删除符合条件的数据10 alter table emp modify name char(125); 修改单个字段的属性,注:modify不能修改字段名11 alter table emp change name cname char(125); 修改单个字段的属性,并能修改字段名次12 alter table emp modify name char(200) first | after birdate 修改单个字段的属性,并指定修改后的位置13 alter table emp add column sex tinyint(1) first | after name 增加一个字段,并可以指定它的位置14 alter table emp delete column sex 删除一个字段15 describe emp 查看一个表的结构 = desc emp16 show create table emp 同上,但更详细17 drop table emp 删除一个表18 select * from emp 查询emp表所有数据19 select name from emp 只查询emp表的name字段20 select distinct name from emp 查询name不重复的数据21 select * from emp where name = 'Php'; 查询name条件为php的数据22 select * from emp where name = 'Php' order by id desc | asc; 条件并排序23 select max(id),min(id),sum(id) from emp 查询最大、最小、总计的id的数据24 select * from emp limit 2 只要2条数据25 select * from emp limit 9,10 从第10条数据开始,取10条数据26 select count(id) from emp 求出一共有多少条数据27 select * from emp where id in(select id from emp where name = 'Php' or name = 'Libin') 子查询,首先查询name为php或libin的id,然后通过in查询所有能匹配id的数据28 select a.name,b.name from emp as a,emp as b where a.id=b.id and a.id=100 id为100的内联(表联)29 select a.name,b.name from emp as a left join emp as b on a.id=b.id where a.id = 100 id为100的左连接30 select a.name,b.name from emp as a right join emp as b on a.id=b.id where a.id = 100 id为100的右连接31 32 DCL::33 grant select,insert on www.* to 'test'@'localhost' identified by '123456' 给www下所有的表创建一个只有select跟insert权限的用户test,密码为12345634 revoke insert on www.* from 'test'@'localhost' 收回test的insert权限35 36 concat('Li','Bin') 字符串拼接函数,可对查询的结果字段直接进行拼接37 38 select '<?php echo 100;?>' into outfile 'c://qqq.php' 文本输出,简直是个危险的漏洞39 select load_file('c://qqq.php'); 读取一个文本
Copy after login

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!