2013年3月7日 星期四

MYSQL


MySQL

MySQL修改密碼與忘記密碼重設 - http://emn178.pixnet.net/blog/post/87659567-ysql%E4%BF%AE%E6%94%B9%E5%AF%86%E7%A2%BC%E8%88%87%E5%BF%98%E8%A8%98%E5%AF%86%E7%A2%BC%E9%87%8D%E8%A8%AD

CENTOS 安裝 mysql
yum install mysql mysql-server

移除rpm

mysql 有問題可能是之前裝了mysql-cluster

rpm -qa | egrep -i mysql* #找出之前的mysql-rpm
rpm -e mysql-cluster... #移除rpm

SQL語法

SQL 運算子大全
1.SELECT - 選取資料
SELECT * FROM table_name

或

SELECT LastName,FirstName FROM Persons
2.DISTINCT - 選取相異資料
SELECT DISTINCT City FROM Persons
3.WHERE - 指定條件
SELECT * FROM Persons
WHERE City='Sandnes'
4.AND與OR運算子範例
SELECT * FROM Persons WHERE
LastName='Svendson'
AND (FirstName='Tove' OR FirstName='Ola')
5.ORDER BY - 設定排序
SELECT * FROM Persons
ORDER BY LastName

或

SELECT * FROM Persons
ORDER BY LastName DESC
6.INSERT - 插入新資料
INSERT INTO Persons
VALUES (4,'Nilsen', 'Johan', 'Bakken 2', 'Stavanger')

或

INSERT INTO Persons (P_Id, LastName, FirstName)
VALUES (5, 'Tjessem', 'Jakob')
7.UPDATE - 更新資料
UPDATE Persons
SET Address='Nissestien 67', City='Sandnes'
WHERE LastName='Tjessem' AND FirstName='Jakob'
8.DELETE - 刪除資料
DELETE FROM Persons
WHERE LastName='Tjessem' AND FirstName='Jakob'

如果要刪除全部列則下

DELETE FROM table_name

or

DELETE * FROM table_name

沒有留言:

張貼留言