国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
create table tb as select 和create table tb like的區(qū)別
目的:測試create table a as select * from b 與create table a  like b的區(qū)別

mysql下測試:

源表:ti

表結(jié)構(gòu)如下

root:test> show create table ti\G
*************************** 1. row ***************************
       Table: ti
Create Table: CREATE TABLE `ti` (
  `id` int(11) DEFAULT NULL,
  `amount` decimal(7,2) DEFAULT NULL,
  `m_photo_big` varchar(64) DEFAULT NULL,
  `tr_date` date DEFAULT NULL,
  `new_msg_flag` tinyint(4) NOT NULL DEFAULT '0',
  `love_listreq` int(3) DEFAULT '1',
  `love_listconfig` int(3) DEFAULT '1',
  KEY `new_msg_flag` (`new_msg_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

a 使用create as select語句創(chuàng)建表

root:test> create table ti2 as select * from ti limit 0;
Query OK, 0 rows affected (0.00 sec)

sroot:test> how create table ti2 ;
----------------------------
CREATE TABLE `ti2` (
  `id` int(11) DEFAULT NULL,
  `amount` decimal(7,2) DEFAULT NULL,
  `m_photo_big` varchar(64) DEFAULT NULL,
  `tr_date` date DEFAULT NULL,
  `new_msg_flag` tinyint(4) NOT NULL DEFAULT '0',
  `love_listreq` int(3) DEFAULT '1',
  `love_listconfig` int(3) DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1

對比源表的表結(jié)構(gòu),發(fā)現(xiàn)KEY `new_msg_flag` (`new_msg_flag`)沒有被創(chuàng)建


b 使用like子句創(chuàng)建表

root:test> create table ti1 like ti;
Query OK, 0 rows affected (0.06 sec)

root:test> show create table ti1;  
----------------------------------------
CREATE TABLE `ti1` (
  `id` int(11) DEFAULT NULL,
  `amount` decimal(7,2) DEFAULT NULL,
  `m_photo_big` varchar(64) DEFAULT NULL,
  `tr_date` date DEFAULT NULL,
  `new_msg_flag` tinyint(4) NOT NULL DEFAULT '0',
  `love_listreq` int(3) DEFAULT '1',
  `love_listconfig` int(3) DEFAULT '1',
  KEY `new_msg_flag` (`new_msg_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

對比源表的表結(jié)構(gòu),兩者完全一致,完整的包含了表結(jié)構(gòu)和索引

結(jié)論:mysql下create table a as select * from b形式創(chuàng)建的表不包含索引信息,like子句形式包含完整表結(jié)構(gòu)和索引信息

所以 as select 子句一般適用于建表并復(fù)制源表數(shù)據(jù)的情況,like子句適用于只復(fù)制表結(jié)構(gòu)的情況

誤用的風(fēng)險: 索引的缺失對于業(yè)務(wù)的性能是致命的,不必多說.

Oracle下:

a create as select同樣不會創(chuàng)建索引

b oracle不支持like子句

至于如何實現(xiàn)完全創(chuàng)建表結(jié)構(gòu)和索引的方法?現(xiàn)在還沒有
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
oracle里long類型的總結(jié)
數(shù)據(jù)庫(MySQL)開發(fā)技術(shù)題庫 大二下
mysql新建表和修改字段例子
基礎(chǔ)SQL語法:重新記憶!
【140320-02】冗余表設(shè)計sql
mysql copy復(fù)制拷貝表數(shù)據(jù)及結(jié)構(gòu)的幾種方式
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服