MySQL是一種關(guān)系型數(shù)據(jù)庫管理系統(tǒng),它是一款免費(fèi)的開源軟件,因此得到了廣泛的應(yīng)用。下面是MySQL講義,讓你更好地了解MySQL。
MySQL的連接方式:
MySQL的創(chuàng)建數(shù)據(jù)庫和表:
CREATE DATABASE mydatabase; USE mydatabase; CREATE TABLE mytable ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30) NOT NULL, age INT(3) NOT NULL, email VARCHAR(50) );
MySQL的插入數(shù)據(jù):
INSERT INTO mytable (name, age, email) VALUES ('John', 25, 'john@example.com'); INSERT INTO mytable (name, age, email) VALUES ('Mary', 30, 'mary@example.com'); INSERT INTO mytable (name, age, email) VALUES ('Peter', 35, 'peter@example.com');
MySQL的查詢數(shù)據(jù):
SELECT * FROM mytable; SELECT name, age FROM mytable WHERE age >25; SELECT DISTINCT age FROM mytable;
MySQL的更新數(shù)據(jù):
UPDATE mytable SET age = 28 WHERE name = 'Mary'; UPDATE mytable SET email = 'peter@hotmail.com' WHERE id = 3;
MySQL的刪除數(shù)據(jù):
DELETE FROM mytable WHERE name = 'Peter';
MySQL的排序:
SELECT * FROM mytable ORDER BY age DESC; SELECT * FROM mytable ORDER BY name ASC;
MySQL的限制輸出:
SELECT * FROM mytable LIMIT 2; SELECT * FROM mytable LIMIT 1, 2;
以上就是MySQL講義的內(nèi)容,希望對你有所幫助。
上一篇css里面橫線怎么寫
下一篇dw中css面板怎么打開