ORALCE: Select into VS Insert into select(真的暈)

來源:互聯網
上載者:User
select
想實現 一個很簡單的功能 費了我好長時間;
目的: 把一個料號記錄COPY一份修改主鍵再存放到原表裡去;

1) 憑記憶採用

Select * into a from b 的這種形式,死也不行~~

2) 上網GOOGLE了一下

==>http://fengyu.china.com/sql1.htm

INSERT  (往資料表裡插入記錄的語句)

INSERT INTO 表名(欄位名1, 欄位名2, ……) VALUES ( 值1, 值2, ……);
INSERT INTO 表名(欄位名1, 欄位名2, ……)  SELECT (欄位名1, 欄位名2, ……) FROM 另外的表名;

第二個的文法很符合,決定試試.
不想還是提示: 右括弧MISSING!

奇怪,仔細對了一次又一次,發現文法格式和上面的一模一樣;
~~~~~~~~~~~~~~~無語
真試試看把括弧去掉試試
INSERT INTO 表名(欄位名1, 欄位名2, ……)  SELECT 欄位名1, 欄位名2, …… FROM 另外的表名;

OK搞定,真不懂;頭都發暈,算了,記下來,下次說不定又忘記了

INSERT INTO 表名(欄位名1, 欄位名2, ……)  SELECT (欄位名1, 欄位名2, ……) FROM 另外的表名;
==>紅色的括弧一定要去掉~~!!

 

正確貼在下面:

insert into sales_part_tab (CATALOG_NO ,contract,PART_NO,CATALOG_GROUP,BONUS_BASIS_FLAG,BONUS_VALUE_FLAG,
ENG_ATTRIBUTE,CUSTOMS_STAT_NO,NOTE_ID,DISCOUNT_GROUP,PRINT_CONTROL_CODE,
NOTE_TEXT,PACKAGE_TYPE,SALES_UNIT_MEAS,PACKAGE_WEIGHT,ACTIVEIND,PRICE_CONV_FACTOR,
CATALOG_DESC,PRICE_UNIT_MEAS,CATALOG_TYPE,CONV_FACTOR,COST,DATE_ENTERED,
LIST_PRICE,PRICE_CHANGE_DATE,PURCHASE_FLAG,SO_FLAG,VOLUME,WEIGHT_GROSS,WEIGHT_NET,
FEE_CODE,TAXABLE,PROPOSED_PARCEL_QTY,CLOSE_TOLERANCE,SALES_PRICE_GROUP_ID,
CONFIGURATION,WARRANTY,CREATE_SM_OBJECT_OPTION,EAN_NO,SALES_PART_SOURCING,
EXPECTED_AVERAGE_PRICE,PURCHASE_PART_NO,REPLACEMENT_PART_NO,DATE_OF_REPLACEMENT,
CUST_WARRANTY_ID,NON_INV_PART_TYPE,INTRASTAT_CONV_FACTOR,ROWVERSION )

select CATALOG_NO,'PCB',PART_NO,CATALOG_GROUP,BONUS_BASIS_FLAG,BONUS_VALUE_FLAG,
ENG_ATTRIBUTE,CUSTOMS_STAT_NO,NOTE_ID,DISCOUNT_GROUP,PRINT_CONTROL_CODE,
NOTE_TEXT,PACKAGE_TYPE,SALES_UNIT_MEAS,PACKAGE_WEIGHT,ACTIVEIND,PRICE_CONV_FACTOR,
CATALOG_DESC,PRICE_UNIT_MEAS,CATALOG_TYPE,CONV_FACTOR,COST,DATE_ENTERED,
LIST_PRICE,PRICE_CHANGE_DATE,PURCHASE_FLAG,SO_FLAG,VOLUME,WEIGHT_GROSS,WEIGHT_NET,
FEE_CODE,TAXABLE,PROPOSED_PARCEL_QTY,CLOSE_TOLERANCE,SALES_PRICE_GROUP_ID,
CONFIGURATION,WARRANTY,CREATE_SM_OBJECT_OPTION,EAN_NO,SALES_PART_SOURCING,
EXPECTED_AVERAGE_PRICE,PURCHASE_PART_NO,REPLACEMENT_PART_NO,DATE_OF_REPLACEMENT,
CUST_WARRANTY_ID,NON_INV_PART_TYPE,INTRASTAT_CONV_FACTOR,ROWVERSION

from sales_part_tab where catalog_no = '810370111F1291' and contract = 'TMP'


 


相關文章

Beyond APAC's No.1 Cloud

19.6% IaaS Market Share in Asia Pacific - Gartner IT Service report, 2018

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。