欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

mysql語言的基本語句及例句

阮建安2年前7瀏覽0評論

MySQL是一種關系型數據庫管理系統,它支持SQL語言。SQL是結構化查詢語言的簡稱,用于在關系型數據庫中查詢、插入、更新和刪除數據。以下是MySQL中常見的基本語句及其例子:

1. 創建數據庫
CREATE DATABASE example;
2. 切換數據庫
USE example;
3. 創建表
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. 插入數據
INSERT INTO customers (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com');
5. 查詢數據
SELECT * FROM customers;
6. 更新數據
UPDATE customers SET email='john.doe@example.com' WHERE id=1;
7. 刪除數據
DELETE FROM customers WHERE id=1;
8. 建立索引
CREATE INDEX idx_lastname ON customers (lastname);
9. 聯合查詢
SELECT a.firstname, a.lastname, b.order_date
FROM customers a
INNER JOIN orders b ON a.id = b.customer_id;
10. 使用子查詢
SELECT firstname, lastname
FROM customers WHERE id IN (SELECT customer_id FROM orders);