第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

MySQL的基本語句1

標(biāo)簽:
MySQL
sql语句不区分大小写,语句以英文分号结尾;(下文中,大写部分为非必写内容)

一、数据库相关
1.查看所有数据库:show databases;
2.创建数据库:
create database 数据库名 CHARACTER SET UTF8/GBK;
如:create database db1 character set gbk;
如:create database db2;

3.查看指定数据库:
show create database 数据库名;
如:show create database db1;

4.删除数据库:
drop database 数据库名;
如:drop database db2;

5.使用指定数据库:(只有使用了数据库,才能建表,不然谁知道你要把表建在哪个数据库)
use 数据库名;
如:use db1;

二、表相关
1.查看所有表:show tables;
2.创建表:
create table 表名(字段1名 字段1类型,字段2名 字段2类型,... ...) ENGINE=INNODB/MYISAM CHARSET=UTF8/GBK;
如:create table student(id int, name varchar(20),age int);
如:create table emp(id int, name varchar(20),age int)engine=innodb charset=gbk;

3.查看指定表:
show create table 表名;
如:show create table student;

4.查询表字段信息:
desc 表名;
如:desc student;

5.修改表名:
rename table 原表名 to 新表名;
如:rename table student to teacher;

6.修改引擎(engine)和字符集
alter table 表名 engine=innodb/myisam charset=utf8/gbk;
如:alter table emp engine=myisam charset=utf8;
(也可只修改一项)
如:alter table emp charset=gbk;

7.删除表:
drop table 表名;
如:drop table emp;

三、字段相关(我觉得字段相关是最难记的)
(字段,就是teacher表中name,id,age这些东东,desc teacher可查看teacher表的字段信息)

1.添加字段:add。
(1)alter table 表名 add 字段名 字段类型;(默认添加到最后面)
如:alter table teacher add gender varchar(10);
(2)alter table 表名 add 字段名 字段类型 first;(添加到最前面)
如:不举例了
(3)alter table 表名 add 字段名 字段类型 after 已有字段名;(添加到已有字段名的后面)
如:alter table teacher add score double after id;(在id后面添加一个score字段)

2.删除字段:drop。
alter table 表名 drop 字段名;
如:alter table teacher drop score;

3.修改字段
(1)修改字段名和类型:change。
alter table 表名 change 原字段名 新字段名 新字段类型;
如:alter table teacher change age height double;
(2)修改字段类型和位置:modify。
alter table 表名 modify 字段名 新类型 first/after 已有字段名;
如:alter table teacher modify height int first;(最前面)
如:alter table teacher modify height int after name;(name后面)
如:alter table teacher modify height int;(最后面)
點(diǎn)擊查看更多內(nèi)容
2人點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消