亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch08.htm

?? 21精通SQL
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
<P>In this example you tried to insert another <TT>ITEM</TT> called <TT>STRING</TT>
into the <TT>COLLECTION</TT> table. Because this table was created with <TT>ITEM</TT>
as a unique value, it returned the appropriate error. ANSI SQL does not offer a solution
to this problem, but several commercial implementations include extensions that would
allow you to use something like the following:</P>
<PRE><FONT COLOR="#0066FF">IF NOT EXISTS (SELECT * FROM COLLECTION WHERE NAME = 'STRING'

INSERT INTO COLLECTION VALUES('STRING', 50, 'MORE STRING')
</FONT></PRE>
<P>This particular example is supported in the Sybase system.</P>
<P>A properly normalized table should have a unique, or key, field. This field is
useful for joining data between tables, and it often improves the speed of your queries
when using indexes. (See Day 10, &quot;Creating Views and Indexes.&quot;)


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Here's an <TT>INSERT</TT> statement
	that inserts a new employee into a table:</P>
	<PRE><FONT COLOR="#0066FF">SQL&gt; insert into employee_tbl values
     ('300500177', 'SMITHH', 'JOHN');

1 row inserted.</FONT></PRE>
	<P>After hitting Enter, you noticed that you misspelled <TT>SMITH</TT>. Not to fret!
	All you have to do is issue the <TT>ROLLBACK</TT> command, and the row will not be
	inserted. See Day 11, &quot;Controlling Transactions,&quot; for more on the <TT>ROLLBACK</TT>
	command. 
<HR>


</BLOCKQUOTE>

<H3><FONT COLOR="#000077">The INSERT...SELECT Statement</FONT></H3>
<P>The <TT>INSERT...VALUES</TT> statement is useful when adding single records to
a database table, but it obviously has limitations. Would you like to use it to add
25,000 records to a table? In situations like this, the <TT>INSERT...SELECT</TT>
statement is much more beneficial. It enables the programmer to copy information
from a table or group of tables into another table. You will want to use this statement
in several situations. Lookup tables are often created for performance gains. Lookup
tables can contain data that is spread out across multiple tables in multiple databases.
Because multiple-table joins are slower to process than simple queries, it is much
quicker to execute a <TT>SELECT</TT> query against a lookup table than to execute
a long, complicated joined query. Lookup tables are often stored on the client machines
in client/server environments to reduce network traffic.</P>
<P>Many database systems also support temporary tables. (See Day 14, &quot;Dynamic
Uses of SQL.&quot;) Temporary tables exist for the life of your database connection
and are deleted when your connection is terminated. The <TT>INSERT...SELECT</TT>
statement can take the output of a <TT>SELECT</TT> statement and insert these values
into a temporary table.</P>
<P>Here is an example:</P>
<H5>INPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt;<B> insert into tmp_tbl
</B>  2  <B>select * from table;</B></FONT></PRE>
<H5><FONT COLOR="#000000">OUTPUT:</FONT></H5>
<PRE><FONT COLOR="#0066FF">19,999 rows inserted.
</FONT></PRE>
<H5>ANALYSIS:</H5>
<P>You are selecting all the rows that are in <TT>table</TT> and inserting them into
<TT>tmp_tbl</TT>.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Not all database management systems
	support temporary tables. Check the documentation for the specific system you are
	using to determine if this feature is supported. Also, see Day 14 for a more detailed
	treatment of this topic. 
<HR>


</BLOCKQUOTE>

<P>The syntax of the <TT>INSERT...SELECT</TT> statement is as follows:</P>
<H5>SYNTAX:</H5>
<PRE><FONT COLOR="#0066FF">INSERT INTO table_name
(col1, col2...)
SELECT col1, col2...
FROM tablename
WHERE search_condition
</FONT></PRE>
<P>Essentially, the output of a standard <TT>SELECT</TT> query is then input into
a database table. The same rules that applied to the <TT>INSERT...VALUES</TT> statement
apply to the <TT>INSERT...SELECT</TT> statement. To copy the contents of the <TT>COLLECTION</TT>
table into a new table called <TT>INVENTORY</TT>, execute the set of statements in
Example 8.3.
<H4><FONT COLOR="#000077">Example 8.3</FONT></H4>
<P>This example creates the new table <TT>INVENTORY</TT>.</P>
<H5>INPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>CREATE TABLE INVENTORY</B>
  2  <B>(ITEM CHAR(20),</B>
  3 <B> COST NUMBER,</B>
  4  <B>ROOM CHAR(20),</B>
  5  <B>REMARKS CHAR(40));</B></FONT></PRE>
<H5><FONT COLOR="#000000">OUTPUT:</FONT></H5>
<PRE><FONT COLOR="#0066FF">Table created.
</FONT></PRE>
<P>The following <TT>INSERT</TT> fills the new <TT>INVENTORY</TT> table with data
from <TT>COLLECTION</TT>.</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>INSERT INTO INVENTORY (ITEM, COST, REMARKS)</B>
  2  <B>SELECT ITEM, WORTH, REMARKS</B>
  3 <B> FROM COLLECTION;</B>

6 rows created.
</FONT></PRE>
<P>You can verify that the <TT>INSERT</TT> works with this <TT>SELECT</TT> statement:</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>SELECT * FROM INVENTORY;</B>

ITEM                      COST ROOM     REMARKS
-------------------- --------- -------- ----------------------------
NBA ALL STAR CARDS         300          SOME STILL IN BIKE SPOKES
MALIBU BARBIE              150          TAN NEEDS WORK
STAR WARS GLASS            5.5          HANDLE CHIPPED
LOCK OF SPOUSES HAIR         1          HASN'T NOTICED BALD SPOT YET
SUPERMANS CAPE             250          TUGGED ON IT
STRING                    1000          SOME DAY IT WILL BE VALUABLE

6 rows selected.
</FONT></PRE>


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>The data appears to be in the table;
	however, the transaction is not finalized until a <TT>COMMIT</TT> is issued. The
	transaction can be committed either by issuing the <TT>COMMIT</TT> command or by
	simply exiting. See Day 11 for more on the <TT>COMMIT</TT> command. 
<HR>


</BLOCKQUOTE>

<H5>ANALYSIS:</H5>
<P>You have successfully, and somewhat painlessly, moved the data from the <TT>COLLECTION</TT>
table to the new <TT>INVENTORY</TT> table!</P>
<P>The <TT>INSERT...SELECT</TT> statement requires you to follow several new rules:

<UL>
	<LI>The <TT>SELECT</TT> statement cannot select rows from the table that is being
	inserted into.
	<P>
	<LI>The number of columns in the <TT>INSERT INTO</TT> statement must equal the number
	of columns returned from the <TT>SELECT</TT> statement.
	<P>
	<LI>The data types of the columns in the <TT>INSERT INTO</TT> statement must be the
	same as the data types of the columns returned from the <TT>SELECT</TT> statement.
</UL>

<P>Another use of the <TT>INSERT...SELECT</TT> statement is to back up a table that
you are going to drop, truncate for repopulation, or rebuild. The process requires
you to create a temporary table and insert data that is contained in your original
table into the temporary table by selecting everything from the original table. For
example:</P>
<PRE><FONT COLOR="#0066FF">   SQL&gt; <B>insert into copy_table</B>
     2  <B>select * from original_table;</B>
</FONT></PRE>
<P>Now you can make changes to the original table with a clear conscience.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Later today you learn how to input
	data into a table using data from another database format. Nearly all businesses
	use a variety of database formats to store data for their organizations. The applications
	programmer is often expected to convert these formats, and you will learn some common
	methods for doing just that. 
<HR>


</BLOCKQUOTE>

<H2><FONT COLOR="#000077">The UPDATE Statement</FONT></H2>
<P>The purpose of the <TT>UPDATE</TT> statement is to change the values of existing
records. The syntax is</P>
<H5>SYNTAX:</H5>
<PRE><FONT COLOR="#0066FF">UPDATE table_name
SET columnname1 = value1
[, columname2 = value2]...
WHERE search_condition
</FONT></PRE>
<P>This statement checks the <TT>WHERE</TT> clause first. For all records in the
given table in which the <TT>WHERE</TT> clause evaluates to <TT>TRUE</TT>, the corresponding
value is updated.
<H4><FONT COLOR="#000077">Example 8.4</FONT></H4>
<P>This example illustrates the use of the <TT>UPDATE</TT> statement:</P>
<H5>INPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt;<B> UPDATE COLLECTION</B>
  2  <B>SET WORTH = 900</B>
  3  <B>WHERE ITEM = 'STRING';</B></FONT></PRE>
<H5><FONT COLOR="#000000">OUTPUT:</FONT></H5>
<PRE><FONT COLOR="#0066FF">1 row updated.
</FONT></PRE>
<P>To confirm the change, the query</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>SELECT * FROM COLLECTION</B>
  2  <B>WHERE ITEM = 'STRING';</B>
</FONT></PRE>
<P>yields</P>
<PRE><FONT COLOR="#0066FF">ITEM                     WORTH REMARKS
-------------------- --------- ------------------------------

STRING                     900 SOME DAY IT WILL BE VALUABLE
</FONT></PRE>
<P>Here is a multiple-column update:</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>update collection</B>
  2  <B>set worth = 900, item = ball</B>
  3  <B>where item = 'STRING';</B>

1 row updated.
</FONT></PRE>


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Your implementation might use a
	different syntax for multiple-row updates. 
<HR>
</P>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Notice in the set that <TT>900</TT>
	does not have quotes, because it is a numeric data type. On the other hand, <TT>String</TT>
	is a character data type, which requires the quotes. 
<HR>


</BLOCKQUOTE>

<H4><FONT COLOR="#000077">Example 8.5</FONT></H4>
<P>If the <TT>WHERE</TT> clause is omitted, every record in the <TT>COLLECTION</TT>
table is updated with the value given.</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>UPDATE COLLECTION
</B>  2 <B> SET WORTH = 555;</B>

6 rows updated.
</FONT></PRE>
<P>Performing a <TT>SELECT</TT> query shows that every record in the database was
updated with that value:</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>SELECT * FROM COLLECTION;</B>

ITEM                     WORTH REMARKS
-------------------- --------- ------------------------------
NBA ALL STAR CARDS         555 SOME STILL IN BIKE SPOKES
MALIBU BARBIE              555 TAN NEEDS WORK
STAR WARS GLASS            555 HANDLE CHIPPED
LOCK OF SPOUSES HAIR       555 HASN'T NOTICED BALD SPOT YET
SUPERMANS CAPE             555 TUGGED ON IT
STRING                     555 SOME DAY IT WILL BE VALUABLE

6 rows selected.
</FONT></PRE>
<P>You, of course, should check whether the column you are updating allows unique
values only.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>WARNING:</B></FONT><B> </B>If you omit the <TT>WHERE</TT>
	clause from the <TT>UPDATE</TT> statement, all records in the given table are updated.
	
<HR>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产麻豆| 欧美一区二区三区视频免费播放| 精品国产乱码久久久久久1区2区 | 麻豆视频观看网址久久| 99久久99久久精品免费看蜜桃| 欧美在线色视频| 亚洲大片在线观看| 国产蜜臀av在线一区二区三区| 欧美日韩免费高清一区色橹橹 | 久久草av在线| 中文字幕av一区二区三区高| 欧美日韩亚洲国产综合| 国产在线精品一区二区不卡了| 国产亚洲精品久| 日韩一级视频免费观看在线| 亚洲综合色自拍一区| 色94色欧美sute亚洲线路一ni | 欧美午夜不卡在线观看免费| 婷婷夜色潮精品综合在线| 久久综合色播五月| 欧美中文字幕亚洲一区二区va在线| 舔着乳尖日韩一区| 国产精品久久久久影院亚瑟| 日韩一二三区视频| 91免费精品国自产拍在线不卡| 国产麻豆视频一区| 美女视频黄a大片欧美| 欧美成人精精品一区二区频| 亚洲婷婷综合久久一本伊一区| 久久精品欧美一区二区三区麻豆| 欧美成人精品二区三区99精品| 日韩久久久精品| 懂色av一区二区三区免费观看| 日韩va亚洲va欧美va久久| 日韩成人av影视| 亚洲第一二三四区| 蜜桃一区二区三区在线| 成人动漫av在线| 欧美日韩久久一区二区| 国产午夜亚洲精品理论片色戒| 欧美经典三级视频一区二区三区| 一区二区三区在线视频观看58 | 中文成人av在线| 亚洲欧洲日韩在线| 日韩精品一区二区三区四区视频| 国产成人一区二区精品非洲| 国产片一区二区| 久久久久国产精品免费免费搜索| 91精品国产综合久久久久久久久久 | 亚洲三级免费观看| 国产成人综合在线观看| 欧美日本在线播放| 美女尤物国产一区| 日韩一区二区三| 日韩激情视频在线观看| 91精品国产综合久久精品性色| 午夜电影久久久| 欧美日韩国产中文| 亚洲va在线va天堂| 在线观看不卡一区| 日日噜噜夜夜狠狠视频欧美人| 欧美色视频在线| 日韩电影网1区2区| 欧美大片在线观看| 精品一区二区久久久| 国产日韩精品一区二区三区| 成人免费福利片| **欧美大码日韩| 99热精品一区二区| 亚洲成精国产精品女| 欧美一区二区三区婷婷月色 | 国产不卡免费视频| 国产精品女上位| 麻豆精品一区二区综合av| 国产精品每日更新| 色综合中文字幕| 亚洲成av人影院| 欧美成人精品3d动漫h| 欧美xingq一区二区| 久久色.com| 亚洲精品大片www| 国产一区二区在线电影| 成人黄色电影在线| 精品国产乱码久久久久久1区2区| 久久综合色8888| 亚洲国产精品v| 日韩中文字幕1| 91免费看`日韩一区二区| 欧美高清dvd| 亚洲女人的天堂| 麻豆91在线观看| 91福利国产成人精品照片| 亚洲精品一线二线三线无人区| 欧美成人三级电影在线| 丝袜脚交一区二区| 在线免费观看视频一区| 日韩欧美一区二区免费| 蜜臀av一区二区三区| 国产在线播精品第三| 成人黄色国产精品网站大全在线免费观看 | 日韩情涩欧美日韩视频| 久久日韩粉嫩一区二区三区 | 色综合激情五月| 韩国三级中文字幕hd久久精品| 一区二区三区视频在线看| 国产女人18毛片水真多成人如厕 | 欧美人与z0zoxxxx视频| 91香蕉视频在线| 国产黑丝在线一区二区三区| 蜜臀av在线播放一区二区三区| 亚洲成人动漫av| 亚洲一二三区在线观看| 亚洲老司机在线| 亚洲精品亚洲人成人网在线播放| 欧美国产1区2区| 中文字幕精品三区| 国产精品国产a级| 国产精品美女久久久久久2018| 国产午夜精品理论片a级大结局 | 欧美日韩国产另类一区| 色网站国产精品| 在线观看一区不卡| 欧美日韩国产另类一区| 欧美电影一区二区三区| 5月丁香婷婷综合| 欧美一区二区三区视频在线观看 | 6080yy午夜一二三区久久| 在线成人av影院| 成人性生交大片免费看视频在线| 日韩国产一二三区| 亚洲综合在线视频| 丝袜a∨在线一区二区三区不卡| 亚洲图片你懂的| 国产精品初高中害羞小美女文| 国产色婷婷亚洲99精品小说| 日韩一区二区三区电影在线观看| 欧美在线你懂的| 欧洲一区二区av| 欧洲精品在线观看| 7777女厕盗摄久久久| 91福利精品第一导航| 3d成人动漫网站| 91精品国产综合久久小美女| 26uuu国产在线精品一区二区| 在线不卡的av| 久久久久久久久蜜桃| 欧美v国产在线一区二区三区| 国产日韩欧美高清| 国产精品狼人久久影院观看方式| 日本一区二区三区在线观看| 国产精品每日更新在线播放网址| 中文字幕永久在线不卡| 无码av免费一区二区三区试看 | 在线观看欧美日本| 欧美日韩在线播放一区| 欧美日韩免费观看一区二区三区| 精品99999| 一色屋精品亚洲香蕉网站| 亚洲精品久久久蜜桃| 视频精品一区二区| 国产v综合v亚洲欧| 91天堂素人约啪| 欧美精品黑人性xxxx| 精品少妇一区二区| 亚洲天堂成人在线观看| 婷婷六月综合网| 国产成人综合网| 在线视频你懂得一区二区三区| 日韩午夜三级在线| 欧美激情综合网| 亚洲成人久久影院| 久久99国产精品尤物| 麻豆精品视频在线观看免费| 久久伊99综合婷婷久久伊| 欧美国产欧美综合| 天堂成人免费av电影一区| 激情文学综合网| 欧美一区二区三区男人的天堂| 91久久奴性调教| 日本一区二区三区视频视频| 亚洲成人av中文| 色老综合老女人久久久| 日韩一区二区三区电影在线观看| 国产性做久久久久久| 美女被吸乳得到大胸91| 欧美午夜片在线观看| 久久精品欧美日韩| 亚洲高清视频的网址| 成人国产亚洲欧美成人综合网| 国产夫妻精品视频| 欧美变态tickle挠乳网站| 亚洲影院免费观看| 免费三级欧美电影| 中文字幕日韩一区二区| 国产一区视频导航| 国产精品看片你懂得| 日本特黄久久久高潮| 欧美精品在线观看播放| 日韩美女视频在线| 午夜精品福利在线|