一、mysql使用入门
生活随笔
收集整理的這篇文章主要介紹了
一、mysql使用入门
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、mysql使用入門 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); 創(chuàng)建一個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 emp
16 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的內聯(lián)(表聯(lián))
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下所有的表創(chuàng)建一個只有select跟insert權限的用戶test,密碼為123456
34 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'); 讀取一個文本
?
posted on 2014-07-06 08:40?一生學習,何來畢業(yè) 閱讀(...) 評論(...) 編輯 收藏轉載于:https://www.cnblogs.com/shibazi/p/3826701.html
總結
以上是生活随笔為你收集整理的一、mysql使用入门的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 服务器的路径
- 下一篇: oracle 回车、换行符