1.建表
CREATE TABLE students (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
age INT
);
结构解释:
CREATE TABLE [表名] (
[列名] [字段类型] [AUTO_INCREMENT PRIMARY KEY 自增,主键属性],
[列名] [字段类型],
[列名] [字段类型]
);
2.查询
SELECT * FROM students;
结构解释:
SELECT [列名] FROM [表名];
3.更新
UPDATE students SET age = 20 WHERE name = 'John';
结构解释:
UPDATE [表名] SET [列名] = [新的值] WHERE [条件];
4.删除
DELETE FROM students WHERE name = 'John';
结构解释:
DELETE FROM [表名] WHERE [条件语句];
5.插入
INSERT INTO students (name, age) VALUES ('Alice', 18);
结构解释:
INSERT INTO [表名] [列名](name, age) VALUES [值]('Alice', 18);