mysql 常用基础命令
在 mysql 数据库中,基础命令是数据库操作的基石。通过使用这些命令,你可以创建、修改和管理数据库及表。
建表语句
- create table:创建一个新表。
- alter table:修改现有表的结构。
- drop table:删除一个表。
功能型语句
示例
创建一个名为 users 的表:
create table users ( id int not null auto_increment, name varchar(255) not null, email varchar(255) unique not null, primary key (id) );
在 users 表中插入一条记录:
insert into users (name, email) values ('john doe', 'john.doe@example.com');
从 users 表中检索所有记录:
select * from users;
更新 users 表中的记录,将 email 修改为 jane.doe@example.com:
update users set email = 'jane.doe@example.com' where id = 1;
删除 users 表中 id 为 1 的记录:
DELETE FROM users WHERE id = 1;
通过了解这些基础命令,你可以开始探索 mysql 数据库的强大功能。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END