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

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

?? ch08.htm

?? Learn SQL in an easy way...
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD>		<TITLE>Teach Yourself SQL in 21 Days, Second Edition -- Ch 8 -- Manipulating Data</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><CENTER><H1><IMG SRC="../buttonart/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR><FONT COLOR="#000077">Teach Yourself SQL in 21 Days, Second Edition</FONT></H1></CENTER><CENTER><P><A HREF="../ch07/ch07.htm"><IMG SRC="../buttonart/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch09/ch09.htm"><IMGSRC="../buttonart/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../buttonart/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <HR></CENTER><CENTER><H1><FONT COLOR="#000077">- Day 8 -<BR>Manipulating Data</FONT></H1></CENTER><H2><FONT COLOR="#000077">Objectives</FONT></H2><P>Today we discuss data manipulation. By the end of the day, you should understand:<UL>	<LI>How to manipulate data using the <TT>INSERT</TT>, <TT>UPDATE</TT>, and <TT>DELETE</TT>	commands	<P>	<LI>The importance of using the <TT>WHERE</TT> clause when you are manipulating data	<P>	<LI>The basics of importing and exporting data from foreign data sources</UL><H2><FONT COLOR="#000077">Introduction to Data Manipulation Statements</FONT></H2><P>Up to this point you have learned how to retrieve data from a database using everyselection criterion imaginable. After this data is retrieved, you can use it in anapplication program or edit it. Week 1 focused on retrieving data. However, you mayhave wondered how to enter data into the database in the first place. You may alsobe wondering what to do with data that has been edited. Today we discuss three SQLstatements that enable you to manipulate the data within a database's table. Thethree statements are as follows:<UL>	<LI>The <TT>INSERT</TT> statement	<P>	<LI>The <TT>UPDATE</TT> statement	<P>	<LI>The <TT>DELETE</TT> statement</UL><P>You may have used a PC-based product such as Access, dBASE IV, or FoxPro to enteryour data in the past. These products come packaged with excellent tools to enter,edit, and delete records from databases. One reason that SQL provides data manipulationstatements is that it is primarily used within application programs that enable theuser to edit the data using the application's own tools. The SQL programmer needsto be able to return the data to the database using SQL. In addition, most large-scaledatabase systems are not designed with the database designer or programmer in mind.Because these systems are designed to be used in high-volume, multiuser environments,the primary design emphasis is placed on the query optimizer and data retrieval engines.</P><P>Most commercial relational database systems also provide tools for importing andexporting data. This data is traditionally stored in a delimited text file format.Often a format file is stored that contains information about the table being imported.Tools such as Oracle's SQL*Loader, SQL Server's bcp (bulk copy), and Microsoft AccessImport/Export are covered at the end of the day.<BLOCKQUOTE>	<P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Today's examples were generated	with Personal Oracle7. Please note the minor differences in the appearance of commands	and the way data is displayed in the various implementations. <HR></BLOCKQUOTE><H2><FONT COLOR="#000077">The INSERT Statement</FONT></H2><P>The <TT>INSERT</TT> statement enables you to enter data into the database. Itcan be broken down into two statements:</P><PRE><FONT COLOR="#0066FF">INSERT...VALUES</FONT></PRE><P>and</P><PRE><FONT COLOR="#0066FF">INSERT...SELECT</FONT></PRE><H3><FONT COLOR="#000077">The INSERT...VALUES Statement</FONT></H3><P>The <TT>INSERT...VALUES</TT> statement enters data into a table one record ata time. It is useful for small operations that deal with just a few records. Thesyntax of this statement is as follows:</P><H5>SYNTAX:</H5><PRE><FONT COLOR="#0066FF">INSERT INTO table_name(col1, col2...)VALUES(value1, value2...)</FONT></PRE><P>The basic format of the <TT>INSERT...VALUES</TT> statement adds a record to atable using the columns you give it and the corresponding values you instruct itto add. You must follow three rules when inserting data into a table with the <TT>INSERT...VALUES</TT>statement:<UL>	<LI>The values used must be the same data type as the fields they are being added	to.	<P>	<LI>The data's size must be within the column's size. For instance, you cannot add	an 80-character string to a 40-character column.	<P>	<LI>The data's location in the <TT>VALUES</TT> list must correspond to the location	in the column list of the column it is being added to. (That is, the first value	must be entered into the first column, the second value into the second column, and	so on.)</UL><H4><FONT COLOR="#000077">Example 8.1</FONT></H4><P>Assume you have a <TT>COLLECTION</TT> table that lists all the important stuffyou have collected. You can display the table's contents by writing</P><H5>INPUT:</H5><PRE><FONT COLOR="#0066FF">SQL&gt; <B>SELECT * FROM COLLECTION;</B></FONT></PRE><P>which would yield this:</P><H5>OUTPUT:</H5><PRE><FONT COLOR="#0066FF">ITEM                     WORTH REMARKS-------------------- --------- ----------------------------NBA ALL STAR CARDS         300 SOME STILL IN BIKE SPOKESMALIBU BARBIE              150 TAN NEEDS WORKSTAR WARS GLASS            5.5 HANDLE CHIPPEDLOCK OF SPOUSES HAIR         1 HASN'T NOTICED BALD SPOT YET</FONT></PRE><P>If you wanted to add a new record to this table, you would write</P><H5><FONT COLOR="#000000">INPUTOUTPUT:</FONT></H5><PRE><FONT COLOR="#0066FF">SQL&gt;<B> INSERT INTO COLLECTION</B>  2 <B> (ITEM, WORTH, REMARKS) </B> 3 <B> VALUES('SUPERMANS CAPE', 250.00, 'TUGGED ON IT');</B>1 row created.</FONT></PRE><P>You can execute a simple <TT>SELECT</TT> statement to verify the insertion:</P><H5>INPUT/OUTPUT:</H5><PRE><FONT COLOR="#0066FF">SQL&gt; <B>SELECT * FROM COLLECTION;</B>ITEM                     WORTH REMARKS-------------------- --------- ----------------------------NBA ALL STAR CARDS         300 SOME STILL IN BIKE SPOKESMALIBU BARBIE              150 TAN NEEDS WORKSTAR WARS GLASS            5.5 HANDLE CHIPPEDLOCK OF SPOUSES HAIR         1 HASN'T NOTICED BALD SPOT YETSUPERMANS CAPE             250 TUGGED ON IT</FONT></PRE><H5>ANALYSIS:</H5><P>The <TT>INSERT</TT> statement does not require column names. If the column namesare not entered, SQL lines up the values with their corresponding column numbers.In other words, SQL inserts the first value into the first column, the second valueinto the second column, and so on.<H4><FONT COLOR="#000077">Example 8.2</FONT></H4><P>The following statement inserts the values from Example 8.1 into the table:</P><H5>INPUT:</H5><PRE><FONT COLOR="#0066FF">SQL&gt; <B>INSERT INTO COLLECTION VALUES</B>  2 <B> ('STRING',1000.00,'SOME DAY IT WILL BE VALUABLE');</B></FONT></PRE><PRE><FONT COLOR="#0066FF"><B>     </B>1 row created.</FONT></PRE><H5>ANALYSIS:</H5><P>By issuing the same <TT>SELECT</TT> statement as you did in Example 8.1, you canverify that the insertion worked as expected:</P><H5>INPUT:</H5><PRE><FONT COLOR="#0066FF">SQL&gt; <B>SELECT * FROM COLLECTION;</B></FONT></PRE><H5><FONT COLOR="#000000"><B>OUTPUT:</B></FONT></H5><PRE><FONT COLOR="#0066FF">ITEM                     WORTH REMARKS-------------------- --------- ----------------------------NBA ALL STAR CARDS         300 SOME STILL IN BIKE SPOKESMALIBU BARBIE              150 TAN NEEDS WORKSTAR WARS GLASS            5.5 HANDLE CHIPPEDLOCK OF SPOUSES HAIR         1 HASN'T NOTICED BALD SPOT YETSUPERMANS CAPE             250 TUGGED ON ITSTRING                    1000 SOME DAY IT WILL BE VALUABLE6 rows selected.</FONT></PRE><H3><FONT COLOR="#000077">Inserting NULL Values</FONT></H3><P>On Day 9, &quot;Creating and Maintaining Tables,&quot; you learn how to createtables using the <TT>SQL CREATE TABLE</TT> statement. For now, all you need to knowis that when a column is created, it can have several different limitations placedupon it. One of these limitations is that the column should (or should not) be allowedto contain <TT>NULL</TT> values. A <TT>NULL</TT> value means that the value is empty.It is neither a zero, in the case of an integer, nor a space, in the case of a string.Instead, no data at all exists for that record's column. If a column is defined as<TT>NOT NULL</TT> (that column is not allowed to contain a <TT>NULL</TT> value),you must<B> </B>insert a value for that column when using the <TT>INSERT</TT> statement.The <TT>INSERT</TT> is canceled if this rule is broken, and you should receive adescriptive error message concerning your error.<BLOCKQUOTE>	<P><HR><FONT COLOR="#000077"><B>WARNING:</B></FONT><B> </B>You could insert spaces for a	null column, but these spaces will be treated as a value. <TT>NULL</TT> simply means	nothing is there. <HR></P></BLOCKQUOTE><H5>INPUT:</H5><PRE><FONT COLOR="#0066FF">SQL&gt; <B>insert into collection values</B>  2  <B>('SPORES MILDEW FUNGUS', 50.00, ' ');</B></FONT></PRE><H5><FONT COLOR="#000000">OUTPUT:</FONT></H5><PRE><FONT COLOR="#0066FF"> 1 row inserted.</FONT></PRE><H5>ANALYSIS:</H5><P>Using <TT>''</TT> instead of <TT>NULL</TT> inserted a space in the <TT>collection</TT>table. You then can select the space.</P><H5>INPUT/OUTPUT:</H5><PRE><FONT COLOR="#0066FF">SQL&gt; <B>select * from collection</B>  2  <B>where remarks = ' ';</B>ITEM                         WORTH    REMARKS--------------------------- -------- ---------SPORES MILDEW FUNGUS         50.001 row selected.</FONT></PRE><H5>ANALYSIS:</H5><P>The resulting answer comes back as if a <TT>NULL</TT> is there. With the outputof character fields, it is impossible to tell the difference between a null valueand a mere space.</P><P>Assume the column <TT>REMARKS</TT> in the preceding table has been defined as<TT>NOT NULL</TT>. Typing</P><H5>INPUT/OUTPUT:</H5><PRE><FONT COLOR="#0066FF">SQL&gt; <B>INSERT INTO COLLECTION</B>  2 <B> VALUES('SPORES MILDEW FUNGUS',50.00,NULL);</B></FONT></PRE><P>produces the following error:</P><PRE><FONT COLOR="#0066FF">INSERT INTO COLLECTION            *ERROR at line 1:ORA-01400: mandatory (NOT NULL) column is missing or NULL during insert</FONT></PRE><BLOCKQUOTE>	<P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Notice the syntax. Number data types	do not require quotes; <TT>NULL</TT> does not require quotes; character data types	do require quotes. <HR></BLOCKQUOTE><H3><FONT COLOR="#000077">Inserting Unique Values</FONT></H3><P>Many database management systems also allow you to create a <TT>UNIQUE</TT> columnattribute. This attribute means that within the current table, the values withinthis column must be completely unique and cannot appear more than once. This limitationcan cause problems when inserting or updating values into an existing table, as thefollowing exchange demonstrates:</P><H5>INPUT:</H5><PRE><FONT COLOR="#0066FF">SQL&gt; <B>INSERT INTO COLLECTION VALUES('STRING', 50, 'MORE STRING');</B></FONT></PRE><H5><FONT COLOR="#000000">OUTPUT:</FONT></H5><PRE><FONT COLOR="#0066FF">INSERT INTO COLLECTION VALUES('STRING', 50, 'MORE STRING')            *ERROR at line 1:ORA-00001: unique constraint (PERKINS.UNQ_COLLECTION_ITEM) violated</FONT></PRE><H5>ANALYSIS:</H5><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 solutionto this problem, but several commercial implementations include extensions that wouldallow 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 isuseful for joining data between tables, and it often improves the speed of your querieswhen 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 toa database table, but it obviously has limitations. Would you like to use it to add25,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 informationfrom a table or group of tables into another table. You will want to use this statementin several situations. Lookup tables are often created for performance gains. Lookuptables 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 muchquicker to execute a <TT>SELECT</TT> query against a lookup table than to executea long, complicated joined query. Lookup tables are often stored on the client machinesin client/server environments to reduce network traffic.</P><P>Many database systems also support temporary tables. (See Day 14, &quot;DynamicUses of SQL.&quot;) Temporary tables exist for the life of your database connectionand 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 valuesinto 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 tablenameWHERE search_condition</FONT></PRE><P>Essentially, the output of a standard <TT>SELECT</TT> query is then input intoa database table. The same rules that applied to the <TT>INSERT...VALUES</TT> statementapply 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 inExample 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>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美123| 中文字幕一区免费在线观看 | 免费观看日韩av| 另类人妖一区二区av| 国产精选一区二区三区| 91久久人澡人人添人人爽欧美| 91成人在线观看喷潮| 亚洲午夜精品网| 久久se精品一区精品二区| 精品国产乱码久久久久久久| 亚洲欧美日韩国产综合在线| 精品一区二区在线免费观看| 91老师片黄在线观看| 日韩美女视频在线| 国产aⅴ精品一区二区三区色成熟| 欧美日韩国产一区二区三区地区| 国产婷婷色一区二区三区在线| 亚洲成人激情社区| 北岛玲一区二区三区四区| 欧美一级艳片视频免费观看| 亚洲免费av网站| 制服丝袜一区二区三区| 亚洲一区二区av电影| 成人av网在线| 国产欧美日韩三级| 国内精品伊人久久久久av一坑| 4438成人网| 国产精品系列在线观看| 亚洲美女视频在线观看| 欧美一级黄色片| 青椒成人免费视频| 国产精品久久夜| 成人成人成人在线视频| 亚洲电影一区二区三区| 久久久99精品免费观看不卡| 日本韩国视频一区二区| 国产在线精品一区二区| 久久久久久久久久久久久久久99| 久久国产乱子精品免费女| 成人免费在线观看入口| 日韩免费性生活视频播放| 色综合色综合色综合 | 成人美女在线观看| 国产精品久久久久影视| 日韩网站在线看片你懂的| 99久精品国产| 亚洲影院理伦片| 国产精品视频你懂的| www..com久久爱| 激情图区综合网| 日韩精品久久久久久| 精品国产免费视频| 欧美日韩国产综合一区二区三区| 成人av电影免费观看| 精品在线视频一区| 香蕉乱码成人久久天堂爱免费| 中文一区二区在线观看 | 91国在线观看| 成人av在线电影| 国产一区二区伦理片| 老司机免费视频一区二区| 午夜精品爽啪视频| 欧美不卡一区二区三区| 成人午夜激情影院| 国产乱码精品一品二品| 久久国产精品第一页| 蜜桃av一区二区在线观看| 欧美精品一区二区三区高清aⅴ | 国产日韩欧美高清在线| 日韩三级视频中文字幕| 91麻豆精品国产91久久久久久 | 在线观看日韩国产| 日韩精品电影在线| 亚洲第一二三四区| 亚洲国产人成综合网站| 亚洲狠狠爱一区二区三区| 亚洲一区在线电影| 午夜精品久久久久久久| 亚洲国产视频a| 日韩主播视频在线| 日本成人在线不卡视频| **性色生活片久久毛片| 国产精品麻豆视频| 亚洲欧洲三级电影| 亚洲视频免费在线| 久久看人人爽人人| 国产日产欧美精品一区二区三区| 国产人成一区二区三区影院| 欧美激情一区二区在线| 亚洲免费观看视频| 婷婷综合另类小说色区| 日本一不卡视频| 国产在线看一区| 成人a级免费电影| 日本精品一级二级| 欧美一区永久视频免费观看| 欧美电影免费观看高清完整版在线观看| 日韩精品一区二区三区中文不卡| 欧美精品一区二区在线观看| 国产精品素人视频| 一级日本不卡的影视| 中文文精品字幕一区二区| 中文字幕在线不卡| 丝袜诱惑制服诱惑色一区在线观看| 免费三级欧美电影| k8久久久一区二区三区| 欧美在线色视频| 26uuu久久综合| 日韩免费观看高清完整版| 久久久美女毛片| 一区二区三区在线不卡| 蜜桃久久久久久久| 97久久精品人人澡人人爽| 欧美巨大另类极品videosbest | 91性感美女视频| 欧美喷潮久久久xxxxx| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 亚洲欧洲综合另类| 日本 国产 欧美色综合| 成人美女视频在线观看18| 欧美日韩视频第一区| 在线观看网站黄不卡| 欧美精品一区男女天堂| 一区二区三区免费| 激情欧美一区二区| 在线国产电影不卡| 久久久久久97三级| 天天综合天天做天天综合| 国产jizzjizz一区二区| 欧美日韩不卡一区二区| 国产精品国产三级国产普通话99 | 91精品国产乱码久久蜜臀| 国产精品成人一区二区艾草| 久久精品噜噜噜成人av农村| 一本到三区不卡视频| 久久女同精品一区二区| 日日摸夜夜添夜夜添国产精品| 91亚洲精华国产精华精华液| 久久久不卡网国产精品一区| 午夜电影一区二区| 色综合久久九月婷婷色综合| 国产天堂亚洲国产碰碰| 久久精品国产亚洲a| 欧美日韩电影在线| 一区二区在线电影| 全国精品久久少妇| 日本韩国欧美在线| 亚洲日本丝袜连裤袜办公室| 国产成人综合亚洲网站| 色琪琪一区二区三区亚洲区| 亚洲国产经典视频| 久久成人18免费观看| 69久久99精品久久久久婷婷| 一区二区三区中文在线观看| 99久久精品国产网站| 国产欧美视频一区二区| 国产精品一二三| 亚洲精品一区二区三区福利| 蜜臀av性久久久久蜜臀aⅴ流畅| 欧美日韩一区二区三区四区五区| 国产精品传媒视频| 色综合久久88色综合天天| 国产精品盗摄一区二区三区| 99久久精品免费看国产免费软件| 国产日韩欧美综合一区| 风间由美一区二区av101| 国产视频视频一区| 成人91在线观看| 亚洲欧美二区三区| 欧美性感一区二区三区| 久久这里只有精品视频网| 精品亚洲成a人| 久久色在线观看| www.亚洲免费av| 一区二区三区日本| 欧美久久久一区| 麻豆一区二区99久久久久| 亚洲精品一区二区三区影院| 国产成人亚洲综合a∨婷婷| 欧美国产乱子伦 | av高清久久久| 亚洲欧美一区二区三区久本道91| 一本大道久久a久久综合| 亚洲国产欧美日韩另类综合| 制服丝袜av成人在线看| 韩国成人精品a∨在线观看| 国产精品无遮挡| 欧日韩精品视频| 蜜臀av一区二区在线观看| 337p日本欧洲亚洲大胆精品| 岛国av在线一区| 亚洲一区二区欧美激情| 日韩欧美国产一区二区三区| 国产不卡在线一区| 亚洲美女偷拍久久| 精品国产麻豆免费人成网站| 成人av影院在线| 蜜臀av国产精品久久久久 | 国产亚洲一本大道中文在线| 99re这里只有精品视频首页|