mysql创建数据库、表、插入、CURD、删除、更新、查看.......
创建数据库:
CREATE DATABASE IF NOT EXISTS mydatabase;
使用数据库:
USE mydatabase;
创建表:
CREATE TABLE IF NOT EXISTS mytable (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
age INT
);
插入数据:
INSERT INTO mytable (name, age) VALUES ('Alice', 25);
查询数据(查询所有):
SELECT * FROM mytable;
更新数据:
UPDATE mytable SET age = 26 WHERE name = 'Alice';
删除数据:
DELETE FROM mytable WHERE name = 'Alice';
删除表:
DROP TABLE IF EXISTS mytable;
删除数据库:
DROP DATABASE IF EXISTS mydatabase;
评论已关闭