mysql學習筆記 insert擴充套件

2022-08-16 00:06:20 字數 725 閱讀 4390

1、建立表  -利用已有表,建立表

這樣建立的缺點-- 主鍵會丟失

-- 建立表,表結構與資料與t_emptest 一致

create

table t_emptest1 as

select

*from

t_emptest ;

-- 建立空表,表結構與t_emptest 一致

create

table t_emptest1 as

select

*from t_emptest where1=

2;

2、插入資料

-- 插入資料,利用已有表的資料插入新錶中

-- 將t_emptest表中lucy的雇員資訊插入到t_emptest1 表中

insert

into t_emptest1 select

*from t_emptest where ename=

'lucy

'

-- 將lucy所在部門的雇員資訊插入到t_emptest1中

insert

into t_emptest1 select

*from t_emptest where deptno=(select deptno from t_emptest where ename=

'lucy

' )

MySql 學習筆記 INSERT

insert 將一行或者多行插入到表中 insert into table col1,col2.制定列名 若一一對應則可以忽略 values values1,values2.對應屬性值 插入多行 insert ignore into table col1,col2.制定列名,可以選擇忽略錯誤繼續後面...

MySQL 提高Insert效能

插入乙個記錄需要的時間由下列因素組成,其中的數字表示大約比例 這不考慮開啟表的初始開銷,每個併發執行的查詢開啟。表的大小以logn b樹 的速度減慢索引的插入。加快插入的一些方法 有選擇地用create table建立表。執行flush tables語句或命令mysqladmin flush tab...

Mysql迴圈insert資料

開發自測時,資料庫需要造大量資料時,要用到mysql儲存過程相關知識,下面分享下,希望對小夥伴們有所幫助 create procedure test 建立儲存函式 begin declare i int default1 while i 5000 do 下面的insert語法要改成自己的表,同時構造...