use xuexiao;
creat table studentInfo (
name varchar(10),
sex char,
age int,
address varchar(20)
);
show tables;
-- 插入操作
-- 值需要按照字段的順序一一對應(yīng) 洁奈, 如果插入的值順序和創(chuàng)建表順序相同,則字段可以省略
insert into studentInfo(name , sex , age , address ) values ("張三" 魂迄,'男'厨疙,19耐齐, "河南省許昌市");
insert into studentInfo(sex , address , age ,name ) values ("女",'河南省鄭州市',29俊柔,'小紅');
insert into studentInfo values ("小黑"活合,'男'雏婶,39,'河南省滄州市');
select* from studentInfo白指;
-- 修改已創(chuàng)建的表字段默認值
alter table studentInfo change sex sex char default '男';
insert into studentInfo(name , sex , age , address ) values ("翠花" 留晚,'女',19告嘲, "河南省許昌市");
insert into studentInfo(sex , address , age ,name ) values ("女"错维,'河南省鄭州市'奖地,49,'秀蓮')赋焕;
insert into studentInfo values ("黑絲"参歹,'男',29隆判,'河北省邯鄲市');
select* from studentInfo犬庇;
creat table studentInfo2 (
id int auto_increment primary key,
name
varchar(10),
sex char,
age int,
address varchar(20)
);
show tables;
insert into studentInfo2(id , name
, sex , age , address ) values (1 ,"翠花" ,'女' ,18,'河南省許昌市');
insert into studentInfo2(name
, sex , age , address ) values ("翠花" ,'女' ,18,'河南省許昌市');
insert into studentInfo2(id , name
, sex , age , address ) values (3 ,"翠花2" ,'女' ,18,'河南省許昌市');
insert into studentInfo2(id , name
, sex , age , address ) values (2,"翠花2" ,'女' ,18,'河南省許昌市');
insert into studentInfo2(name
,sex,age, address ) values ("黑絲",'男'侨嘀,29械筛,'河北省邯鄲市');
("李逵",'男',29'河北省邯鄲市'),
("宋江",'男',29'河北省邯鄲市'),
("吳用",'男',29'河北省邯鄲市'),
("公孫勝",'男',29'河北省邯鄲市'),
desc studentInfo2,
select * from studentInfo2;
select * from studentInfo;
insert into studentInfo values ("黑絲",'男'飒炎,29埋哟,'河北省邯鄲市');
("李逵",'男',29'河北省邯鄲市'),
("宋江",'男',29'河北省邯鄲市'),
("吳用",'男',29'河北省邯鄲市'),
("公孫勝",'男',29'河北省邯鄲市'),
insert into studentInfo2 values (11,"黑絲",'男'郎汪,29赤赊,'河北省邯鄲市');
(12,"李逵",'男',29'河北省邯鄲市'),
(13,"宋江",'男',29'河北省邯鄲市'),
(14,"吳用",'男',29'河北省邯鄲市'),
(15,"公孫勝",'男',29'河北省邯鄲市'),
select * from studentInfo2;
-- 修改 update ... set ... where 條件
-- 修改指定的數(shù)據(jù)
updatestudentInfo set name="潘金蓮" where name ="秀蓮";
-- 沒有寫條件, 則修改全部的數(shù)據(jù)
update studentInfo srt name="潘金蓮";
-- 刪除 delete from table where ... 有日志留下煞赢,可以恢復(fù)
delete from studentInfo2 where name ="翠花2";-- 刪除符合條件的數(shù)據(jù)
delete from studentInfo; -- 刪除所有的數(shù)據(jù)
-- 銷毀數(shù)據(jù) 不留下日志抛计,速度快,無法恢復(fù)
truncate table studentInfo2;