MySQL學習筆記 3

2022-06-06 06:03:07 字數 1450 閱讀 9076

dml資料操縱語言

② 寫法2

insert into tab_name [(欄位1,欄位2,...)]

select v1,v2,... union

select v1,v2,... union

select ... ;#union 聯合多個子句執行

③ 寫法3

insert into tab_name

set 欄位1 = v1,欄位2 = v2 , .... ;

1.2修改(更新)表中資料 關鍵字update

1.3刪除表中資料 關鍵字delete

1.4查詢表中資料 關鍵字select

​ 條件查詢,分組查詢,連線查詢,聯合查詢,子查詢,排序,分頁查詢等。

ddl資料定義語言

③ 刪除資料庫drop database [if exists] database_name;

2.2表

③刪除表 關鍵字 drop

drop table [if exists] tab_name ;

④表的複製

#複製整個表的結構

create table new_cop_tab_name like org_tab_name;

#複製表的部分結構

create table new_cop_tab_name from

select 欄位1,欄位2

from org_tab_name

where 1=2 或者 where 0;

#將表的結構與資料值同時複製。

create table new_cop_tab_name

select */欄位1,欄位2,...

from org_tab_name

[where clause];

資料型別

mysql supports sql data types in several categories: numeric types, date and time types, string (character and byte) types, spatial types, and the json data type.

mysql支援的資料型別有:數值型,時間型,字串型別,地理空間型別,json型別(詳細參見手冊11章 data types)

常見約束

4.2 檢視表中索引:show index from stuinfo;

4.3標識列/自增長列

tcl事務控制語言

檢視

mysql學習筆記(3)

資料表索引設定 目的 加速搜尋 檢視現有索引 show index from user g 語句以 g 結尾可以使顯示結果行列轉置,方便檢視 1.主鍵索引 primary key eg 給字段id加主鍵索引 建立表時新增 id int unsigned auto increment primary ...

MySQL學習筆記3

標籤 空格分隔 筆記 mysql 通過inner join on關鍵字實現 具體語法 select field1,field2,fieldn from table name inner join join table on join condition 這裡注意的是on後面其實跟的就是外來鍵約束中相...

MySQL學習筆記 3

use test show tables select employee name,salary from employee order by salary desc 執行結果 desc 降序asc 公升序 不寫預設是公升序 use test show tables select employee ...