ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORALCE: Select into VS Insert into select(转)

ORALCE: Select into VS Insert into select(转)

原创 Linux操作系统 作者:jcszjswkzhou 时间:2019-03-23 09:24:05 0 删除 编辑
想实现 一个很简单的功能 费了我好长时间;
目的: 把一个料号记录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'

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-122306/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-08-29

  • 博文量
    3488
  • 访问量
    2618135