MySQL是一種關系型數據庫管理系統,它是一款免費的開源軟件,因此得到了廣泛的應用。下面是MySQL講義,讓你更好地了解MySQL。
MySQL的連接方式:
MySQL的創建數據庫和表:
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的插入數據:
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的查詢數據:
SELECT * FROM mytable; SELECT name, age FROM mytable WHERE age >25; SELECT DISTINCT age FROM mytable;
MySQL的更新數據:
UPDATE mytable SET age = 28 WHERE name = 'Mary'; UPDATE mytable SET email = 'peter@hotmail.com' WHERE id = 3;
MySQL的刪除數據:
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講義的內容,希望對你有所幫助。
上一篇css里面橫線怎么寫
下一篇dw中css面板怎么打開