MySQL是一款開源的關(guān)系型數(shù)據(jù)庫管理系統(tǒng),它被廣泛應(yīng)用于網(wǎng)站和企業(yè)中。以下是制作MySQL數(shù)據(jù)庫的步驟和示例代碼。
1. 創(chuàng)建數(shù)據(jù)庫:
CREATE DATABASE mydatabase;
2. 連接到數(shù)據(jù)庫:
USE mydatabase;
3. 創(chuàng)建表格:
CREATE TABLE customers ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP );
4. 插入數(shù)據(jù):
INSERT INTO customers (firstname, lastname, email) VALUES ('John', 'Doe', 'john@example.com');
5. 查詢數(shù)據(jù):
SELECT * FROM customers;
6. 更新數(shù)據(jù):
UPDATE customers SET lastname='Smith' WHERE id=1;
7. 刪除數(shù)據(jù):
DELETE FROM customers WHERE id=1;
通過以上步驟,您可以成功創(chuàng)建、連接、操作MySQL數(shù)據(jù)庫。