创建表
create table customers
(
cust_id int NOT NULL ATUO_INCREMENT, //自动对该列增量
cust_name char(50) NOT NULL DEFAULT 'xiaoming', //默认值
cust_email char(255) NOT NULL, //不可以为NULL
cust address char(50) NULL, //可以为NULL
PRIMARY KEY (cust_id) //主键,有多个时写在括号中用逗号隔开
)ENGINE = InnoDB;
更新表
添加一列
alter table vendors add vend_phone char(20);
删除一列
alter table vendors drop column vend_phone ;
删除表
drop table customer2;
重命名表
rename table customer2 to cust;
rename table backup_customers to customers,
backup_vendors to vendors;
数据库操作:创建、更新、删除与重命名表
这篇博客介绍了基本的数据库操作,包括如何创建表`customers`,添加列到`vendors`表,删除`vend_phone`列,删除`customer2`表,以及重命名`customer2`和`backup_customers`、`backup_vendors`表。这些操作对于数据库管理和维护至关重要。
1040

被折叠的 条评论
为什么被折叠?



