MySql常用命令集
在windows中MySql以服務形式存在,在使用前應確保此服務已經(jīng)啟動波桩,未啟動可用net start mysql命令啟動裸违。而Linux中啟動時可用“/etc/rc.d/init.d/mysqld start"命令,注意啟動者應具有管理員權限荧呐。
全局管理權限:
FILE: 在MySQL服務器上讀寫文件读拆。
PROCESS: 顯示或殺死屬于其它用戶的服務線程擅憔。
RELOAD: 重載訪問控制表,刷新日志等建椰。
SHUTDOWN: 關閉MySQL服務雕欺。
數(shù)據(jù)庫/數(shù)據(jù)表/數(shù)據(jù)列權限:
Alter: 修改已存在的數(shù)據(jù)表(例如增加/刪除列)和索引。
Create: 建立新的數(shù)據(jù)庫或數(shù)據(jù)表棉姐。
Delete: 刪除表的記錄屠列。
Drop: 刪除數(shù)據(jù)表或數(shù)據(jù)庫。
INDEX: 建立或刪除索引伞矩。
Insert: 增加表的記錄笛洛。
Select: 顯示/搜索表的記錄。
Update: 修改表中已存在的記錄乃坤。
mysql -uUser -pPassword;
show databases;
create database name;
use databasename;
drop database name;
show tables;
describe tablename; desc tablename; show columns from tablename;
select veriosn(),current_date;
mysql -h localhost -u root -p ***;
exit or quit;
describe users;
select database();
drop table tablename;
delete from tablename;
insert into tablename [(columnName,*)] values (value,*);
select * from tablename order by id limit 2;
delete from tablename where ***;
update tablename set key=value where **;
alter table tablename add column type;
Select[ALL|DISTINCT|DISTINCTROW|TOP]
{*|talbe.*|[table.]field1[AS alias1][,[table.]field2[AS alias2][,…]]}
FROM tableexpression[,…][IN externaldatabase]
[Where…]
[GROUP BY…]
[HAVING…]
[ORDER BY…]
[WITH OWNERACCESS OPTION]
Select FirstName AS NickName ,LastName ,City FROM Employees
Select orderID, CustomerID, orderDate FROM orders Where orderDate>#1/1/96# AND orderDate<#1/30/96# 日期用'#'定界
Where orderDate>Datevalue('1/1/96')
Select CustomerID, CompanyName, ContactName, City FROM Customers Where City In('London',' Paris',' Berlin')
Select CustomerID ,CompanyName,City,Phone FROM Customers Where Phone Like '(171)555-####'
Select ProductName,UnitPrice, UnitInStock FROM Products orDER BY 1 DESC , 2 DESC,3
Delete * FROM orders Where orderData<#94-1-1#
Select * INTO ordersArchive FROM orders