Home Article Practice mysql_test

mysql_test

2024-08-26 16:35  views:160  source:2624577239    

-- 创建表
CREATE TABLE teacher (
teacher_id INT UNSIGNED PRIMARY KEY auto_increment,
name VARCHAR(26),
age INT UNSIGNED
);
-- 删除表
drop table teacher;
drop table if exists teacher;
-- 添加数据
insert into teacher values (0,'老夫子',66);
insert into teacher(name)values('孙悟空');
-- 添加多行数据
insert into teacher values(0,'韩信',22),(0,'张良',23),(0,'萧何',23);
insert into teacher(name,age)values('张三',23),('李四',24),('王五',25);
-- 修改数据
update teacher set age=1000 where name='孙悟空';
-- 删除数据
delete from teacher where teacher_id=9;
-- -- 其他删除数据的方法
-- truncate table 表名; 清除表中数据但保留表结构,自增id会从1开始
-- drop table 表名;删除数据表包括表中数据及表结构



Disclaimer: The above articles are added by users themselves and are only for typing and communication purposes. They do not represent the views of this website, and this website does not assume any legal responsibility. This statement is hereby made! If there is any infringement of your rights, please contact us promptly to delete it.

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)