MySQL_数据库的DDL语句(表的创建与修改)
创建表:
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL,
email VARCHAR(100)
);
修改表:
- 添加列:
ALTER TABLE users ADD age INT;
- 修改列:
ALTER TABLE users MODIFY age TINYINT NOT NULL;
- 重命名列:
ALTER TABLE users CHANGE age age_numeric TINYINT NOT NULL;
- 删除列:
ALTER TABLE users DROP COLUMN age_numeric;
- 重命名表:
RENAME TABLE users TO users_info;
- 删除表:
DROP TABLE IF EXISTS users_info;
评论已关闭