My SQL 常見語句

2021-08-25 14:40:47 字數 1218 閱讀 9468

1、建立資料庫 fruit

create database fruit;
2、選擇資料庫

use fruit;
3、刪除資料庫

drop fruit;
4.檢視資料庫

show fruit;

2.更新表

①向表中增加新列 color

add column color char(10);

②刪除表中多餘的列

drop column color;

3.重新命名表

rename table fruit to vegetables
4.刪除表

5.檢視表

6.顯示資料庫中所有的表

use fruit;

database changed

show tables;

7.顯示表的結構

1.建立索引

①公升序索引

create index eat
②降序索引

create index eat
2.檢視索引

show index eat;
3.刪除索引

1.插入資料

values(001,紅色);

2.刪除資料

where color="紅色"

3.更新資料

將表中id為001的資料,color更新為「綠色」

set color='綠色'

where id='001';

常見MySQL語句

1.獲取表的儲存引擎相關資訊 show table status like tablename 2.檢查表錯誤 check table tablename 3.修復表 repair table tablename myisam不支援 4.表儲存引擎的改變 alter table tablename ...

Mysql常見語句

alter table 表名 add 列名 varchar 20 default null comment 注釋 after 某列名 例 在user表增加備註欄位125長度,在username列後 alter table user add remarks varchar 125 default nu...

Mysql語句常見查詢(基礎篇)

一些基礎的sql語句,最近在看sql語句,和sql的優化,就在筆記中做了些總結,不全面,以後會進行一些補充。sql基礎內容 1,select from user 查詢user表所有 2,select distinct user age user name from user 查詢所有不重複的user...