注意事項(xiàng):
1.默認(rèn)自增用0,null, default
2.多個(gè)字段英文逗號(hào)表示
3.vachar用雙引號(hào)
4.所有的符號(hào)用英文表示
一.創(chuàng)建表
創(chuàng)建表
creat table 表名(
id int unsigened priary key auto_increment,
name varchar(10),
)
添加字段:alter table 表名 add 列名 int
二.簡(jiǎn)單查詢
查詢?nèi)浚簊elect *from 表名
查詢列:select 字段名,from 表名
去重查詢:select DISTINCT 字段名 from 表名
起別名:
1.給字段起別名:select name as 姓名 from 表名
2.給表起別名:select name as 姓名 from 表名 as 學(xué)生表
三.基礎(chǔ)增刪改查
如果表存在就刪除,不存在就報(bào)錯(cuò):drop table 表名
如果表存在則刪除,如果不存在不會(huì)報(bào)錯(cuò):drop table if exists 表名
新增一條數(shù)據(jù):insert into 表名 values (,'',..)
增加指定的字段:insert into 表名(name) values(''),('')
刪除指定數(shù)據(jù):delete from 表名 where id=1
刪除表中全部數(shù)據(jù):delete from 表名
修改全部數(shù)據(jù):update 表名 set 字段名=值
修改指定數(shù)據(jù):update 表名 set 列名='',列名=值 where id=值