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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ch09.htm

?? 21精通SQL
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
		<TD ALIGN="LEFT"><TT>BALANCE, NUMBER</TT></TD>
		<TD ALIGN="LEFT"><TT>CITY, CHAR(20)</TT></TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"></TD>
		<TD ALIGN="LEFT"><TT>BANK, CHAR(30)</TT></TD>
		<TD ALIGN="LEFT"><TT>STATE, CHAR(2)</TT></TD>
	</TR>
</TABLE>
</P>
<P>Take a moment to examine these tables. Which fields do you think are the primary
keys? Which are the foreign keys?</P>
<P>The primary key in the <TT>BILLS</TT> table is the <TT>NAME</TT> field. This field
should not be duplicated because you have only one bill with this amount. (In reality,
you would probably have a check number or a date to make this record truly unique,
but assume for now that the <TT>NAME</TT> field works.) The <TT>ACCOUNT_ID</TT> field
in the <TT>BANK_ACCOUNTS</TT> table is the primary key for that table. The <TT>NAME</TT>
field is the primary key for the <TT>COMPANY</TT> table.</P>
<P>The foreign keys in this example are probably easy to spot. The <TT>ACCOUNT_ID</TT>
field in the <TT>BILLS</TT> table joins the <TT>BILLS</TT> table with the <TT>BANK_ACCOUNTS</TT>
table. The <TT>NAME</TT> field in the <TT>BILLS</TT> table joins the <TT>BILLS</TT>
table with the <TT>COMPANY</TT> table. If this were a full-fledged database design,
you would have many more tables and data breakdowns. For instance, the <TT>BANK</TT>
field in the <TT>BANK_ACCOUNTS</TT> table could point to a <TT>BANK</TT> table containing
bank information such as addresses and phone numbers. The <TT>COMPANY</TT> table
could be linked with another table (or database for that matter) containing information
about the company and its products.
<H4><FONT COLOR="#000077">Exercise 9.1</FONT></H4>
<P>Let's take a moment to examine an incorrect database design using the same information
contained in the <TT>BILLS</TT>, <TT>BANK_ACCOUNTS</TT>, and <TT>COMPANY </TT>tables.
A mistake many beginning users make is not breaking down their data into as many
logical groups as possible. For instance, one poorly designed <TT>BILLS</TT> table
might look like this: 
<TABLE BORDER="1">
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><B>Column Names</B></TD>
		<TD ALIGN="LEFT"><B>Comments</B></TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><TT>NAME, CHAR(30)</TT></TD>
		<TD ALIGN="LEFT">Name of company that bill is owed to</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><TT>AMOUNT, NUMBER</TT></TD>
		<TD ALIGN="LEFT">Amount of bill in dollars</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><TT>ACCOUNT_ID, NUMBER</TT></TD>
		<TD ALIGN="LEFT">Bank account number of bill (linked to <TT>BANK_ACCOUNTS</TT> table)</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><TT>ADDRESS, CHAR(30)</TT></TD>
		<TD ALIGN="LEFT">Address of company that bill is owed to</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><TT>CITY, CHAR(15)</TT></TD>
		<TD ALIGN="LEFT">City of company that bill is owed to</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><TT>STATE, CHAR(2)</TT></TD>
		<TD ALIGN="LEFT">State of company that bill is owed to</TD>
	</TR>
</TABLE>
</P>
<P>The results may look correct, but take a moment to really look at the data here.
If over several months you wrote several bills to the company in the <TT>NAME</TT>
field, each time a new record was added for a bill, the company's <TT>ADDRESS</TT>,
<TT>CITY</TT>, and <TT>STATE</TT> information would be duplicated. Now multiply that
duplication over several hundred or thousand records and then multiply that figure
by 10, 20, or 30 tables. You can begin to see the importance of a properly normalized
database.</P>
<P>Before you actually fill these tables with data, you will need to know how to
create a table.
<H2><FONT COLOR="#000077">The CREATE TABLE Statement</FONT></H2>
<P>The process of creating a table is far more standardized than the <TT>CREATE DATABASE</TT>
statement. Here's the basic syntax for the <TT>CREATE TABLE</TT> statement:</P>
<H5>SYNTAX:</H5>
<PRE><FONT COLOR="#0066FF">CREATE TABLE table_name
(     field1 datatype [ NOT NULL ],
      field2 datatype [ NOT NULL ],
      field3 datatype [ NOT NULL ]...)
</FONT></PRE>
<P>A simple example of a <TT>CREATE TABLE</TT> statement follows.</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt;  <B>CREATE TABLE BILLS (</B>
  2   <B>NAME CHAR(30),</B>
  3  <B> AMOUNT NUMBER,</B>
  4   <B>ACCOUNT_ID NUMBER);</B>

Table created.
</FONT></PRE>
<H5>ANALYSIS:</H5>
<P>This statement creates a table named <TT>BILLS</TT>. Within the <TT>BILLS</TT>
table are three fields: <TT>NAME</TT>, <TT>AMOUNT</TT>, and <TT>ACCOUNT_ID</TT>.
The <TT>NAME</TT> field has a data type of character and can store strings up to
30 characters long. The <TT>AMOUNT</TT> and <TT>ACCOUNT_ID</TT> fields can contain
number values only.</P>
<P>The following section examines components of the <TT>CREATE TABLE</TT> command.
<H3><FONT COLOR="#000077">The Table Name</FONT></H3>
<P>When creating a table using Personal Oracle7, several constraints apply when naming
the table. First, the table name can be no more than 30 characters long. Because
Oracle is case insensitive, you can use either uppercase or lowercase for the individual
characters. However, the first character of the name must be a letter between <TT>A</TT>
and <TT>Z</TT>. The remaining characters can be letters or the symbols <TT>_</TT>,
<TT>#</TT>, <TT>$</TT>, and <TT>@</TT>. Of course, the table name must be unique
within its schema. The name also cannot be one of the Oracle or SQL reserved words
(such as <TT>SELECT</TT>).


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>You can have duplicate table names
	as long as the owner or schema is different. Table names in the same schema must
	be unique. 
<HR>


</BLOCKQUOTE>

<H3><FONT COLOR="#000077">The Field Name</FONT></H3>
<P>The same constraints that apply to the table name also apply to the field name.
However, a field name can be duplicated within the database. The restriction is that
the field name must be unique within its table. For instance, assume that you have
two tables in your database: <TT>TABLE1</TT>and <TT>TABLE2</TT>. Both of these tables
could have fields called ID. You cannot, however, have two fields within <TT>TABLE1</TT>
called <TT>ID</TT>, even if they are of different data types.
<H3><FONT COLOR="#000077">The Field's Data Type</FONT></H3>
<P>If you have ever programmed in any language, you are familiar with the concept
of data types, or the type of data that is to be stored in a specific field. For
instance, a character data type constitutes a field that stores only character string
data. Table 9.2 shows the data types supported by Personal Oracle7.
<H4><FONT COLOR="#000077">Table 9.2. Data types supported by Personal Oracle7.</FONT></H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><B>Data Type</B></TD>
		<TD ALIGN="LEFT"><B>Comments</B></TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CHAR</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Alphanumeric data with a length between 1 and 255 characters. Spaces are padded to
			the right of the value to supplement the total allocated length of the column.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DATE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Included as part of the date are century, year, month, day, hour, minute, and second.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>LONG</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Variable-length alphanumeric strings up to 2 gigabytes. (See the following note.)</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>LONG RAW</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Binary data up to 2 gigabytes. (See the following note.)</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>NUMBER</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Numeric <TT>0</TT>, positive or negative fixed or floating-point data.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>RAW</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Binary data up to 255 bytes.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ROWID</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Hexadecimal string representing the unique address of a row in a table. (See the
			following note.)</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>VARCHAR2</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Alphanumeric data that is variable length; this field must be between 1 and 2,000
			characters long.</TD>
	</TR>
</TABLE>



<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>The <TT>LONG</TT> data type is often
	called a <TT>MEMO</TT> data type in other database management systems. It is primarily
	used to store large amounts of text for retrieval at some later time.</P>
	<P>The <TT>LONG RAW</TT> data type is often called a binary large object (<TT>BLOB</TT>)
	in other database management systems. It is typically used to store graphics, sound,
	or video data. Although relational database management systems were not originally
	designed to serve this type of data, many multimedia systems today store their data
	in <TT>LONG RAW</TT>, or <TT>BLOB</TT>, fields.<BR>
	<BR>
	The <TT>ROWID</TT> field type is used to give each record within your table a unique,
	nonduplicating value. Many other database systems support this concept with a <TT>COUNTER</TT>
	field (Microsoft Access) or an <TT>IDENTITY</TT> field (SQL Server). 
<HR>
</P>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Check your implementation for supported
	data types as they may vary. 
<HR>


</BLOCKQUOTE>

<H4><FONT COLOR="#000077">The NULL Value</FONT></H4>
<P>SQL also enables you to identify what can be stored within a column. A <TT>NULL</TT>
value is almost an oxymoron, because having a field with a value of <TT>NULL</TT>
means that the field actually has no value stored in it.</P>
<P>When building a table, most database systems enable you to denote a column with
the <TT>NOT NULL</TT> keywords. <TT>NOT NULL</TT> means the column cannot contain
any <TT>NULL</TT> values for any records in the table. Conversely, <TT>NOT NULL</TT>
means that every record must have an actual value in this column. The following example
illustrates the use of the <TT>NOT NULL</TT> keywords.</P>
<H5>INPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B> CREATE TABLE BILLS (</B>
 2    <B>NAME CHAR(30) NOT NULL,</B>
 3    <B>AMOUNT NUMBER,</B>
 4    <B>ACCOUNT_ID NOT NULL);</B>
</FONT></PRE>
<H5>ANALYSIS:</H5>
<P>In this table you want to save the name of the company you owe the money to, along
with the bill's amount. If the <TT>NAME</TT> field and/or the <TT>ACCOUNT_ID</TT>
were not stored, the record would be meaningless. You would end up with a record
with a bill, but you would have no idea whom you should pay.</P>
<P>The first statement in the next example inserts a valid record containing data
for a bill to be sent to Joe's Computer Service for $25.</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>INSERT INTO BILLS VALUES(&quot;Joe's Computer Service&quot;, 25, 1);</B>

1 row inserted.</FONT></PRE>
<H5><FONT COLOR="#000000">INPUT/OUTPUT:</FONT></H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>INSERT INTO BILLS VALUES(&quot;&quot;, 25000, 1);</B>

1 row inserted.
</FONT></PRE>
<H5>ANALYSIS:</H5>
<P>Notice that the second record in the preceding example does not contain a <TT>NAME</TT>
value. (You might think that a missing payee is to your advantage because the bill
amount is $25,000, but we won't consider that.) If the table had been created with
a <TT>NOT NULL</TT> value for the <TT>NAME</TT> field, the second insert would have
raised an error.</P>
<P>A good rule of thumb is that the primary key field and all foreign key fields
should never contain <TT>NULL</TT> values.
<H4><FONT COLOR="#000077">Unique Fields</FONT></H4>
<P>One of your design goals should be to have one unique column within each table.
This column or field is a primary key field. Some database management systems allow
you to set a field as unique. Other database management systems, such as Oracle and
SQL Server, allow you to create a unique index on a field. (See Day 10.) This feature
keeps you from inserting duplicate key field values into the database.</P>
<P>You should notice several things when choosing a key field. As we mentioned, Oracle
provides a <TT>ROWID</TT> field that is incremented for each row that is added, which
makes this field by default always a unique key. <TT>ROWID</TT> fields make excellent
key fields for several reasons. First, it is much faster to join on an integer value
than on an 80-character string. Such joins result in smaller database sizes over
time if you store an integer value in every primary and foreign key as opposed to
a long <TT>CHAR</TT> value. Another advantage is that you can use <TT>ROWID</TT>
fields to see how a table is organized. Also, using <TT>CHAR</TT> values leaves you
open to a number of data entry problems. For instance, what would happen if one person
entered <TT>111 First Street</TT>, another entered <TT>111 1st Street</TT>, and yet

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99精品欧美一区二区三区小说| 粉嫩久久99精品久久久久久夜| 成人手机在线视频| 26uuu色噜噜精品一区二区| 午夜精品福利在线| 欧美日韩一区二区三区四区五区| 亚洲欧美在线高清| 极品瑜伽女神91| 欧美日韩精品电影| 日韩av电影免费观看高清完整版 | jlzzjlzz欧美大全| 国产午夜精品久久久久久久| 国产河南妇女毛片精品久久久 | 欧美一区二区免费观在线| 亚洲va欧美va天堂v国产综合| 欧美日韩五月天| 老司机精品视频一区二区三区| 精品国产污网站| 成人毛片在线观看| 午夜亚洲福利老司机| 日韩欧美久久一区| 懂色av一区二区三区免费观看| 最近日韩中文字幕| 日韩一二三区视频| 91在线观看一区二区| 视频一区视频二区中文字幕| 日韩一区二区免费在线观看| 国产91丝袜在线播放0| 性感美女极品91精品| 久久精品一区八戒影视| 国产成人精品免费| 午夜婷婷国产麻豆精品| 日韩欧美电影一区| 99精品视频中文字幕| 美国一区二区三区在线播放| 欧美国产精品一区| 91精品国产综合久久久蜜臀图片| 国产精品99久久久| 亚洲成人av一区二区三区| 日韩欧美国产综合一区 | 欧美一区二区三区白人| 一本到不卡免费一区二区| 日韩在线a电影| 一二三四区精品视频| 自拍偷拍亚洲综合| 久久国产精品无码网站| 久久久久久日产精品| 久久久午夜精品| 国产偷国产偷亚洲高清人白洁| 日韩欧美电影一二三| 日韩一级片网址| 欧美成人艳星乳罩| 久久综合国产精品| 国产日韩欧美a| 日韩一区在线看| 亚洲另类春色校园小说| 亚洲韩国一区二区三区| 亚洲丶国产丶欧美一区二区三区| 一区二区三区高清在线| 亚洲香肠在线观看| 日本vs亚洲vs韩国一区三区| 国产一区二区不卡在线| 色婷婷av一区二区三区大白胸| 免费美女久久99| 一区在线观看视频| 久久综合九色综合欧美亚洲| 精品视频免费在线| 色琪琪一区二区三区亚洲区| 色综合中文字幕国产| 色一情一伦一子一伦一区| 97久久精品人人澡人人爽| 在线电影一区二区三区| 91精品国产综合久久精品图片| 欧美日韩不卡在线| 久久综合九色综合欧美亚洲| 国产精品理论片在线观看| 亚洲精品综合在线| 极品少妇一区二区三区精品视频 | 日韩欧美国产三级| 欧美日韩久久不卡| 26uuu亚洲| 日韩不卡一区二区| 色就色 综合激情| 欧美哺乳videos| 亚洲欧洲一区二区三区| 一区二区三区不卡在线观看| 美女免费视频一区二区| 国产福利91精品一区| 在线观看欧美精品| 中文在线一区二区| 久久99久久精品| 日韩一区二区在线看片| 亚洲精品国产无天堂网2021| 粉嫩蜜臀av国产精品网站| 亚洲第一主播视频| 免费人成在线不卡| 欧美另类z0zxhd电影| 国产日产欧美一区二区三区| 亚洲男女毛片无遮挡| 国内精品国产三级国产a久久| 欧美在线视频日韩| 综合欧美亚洲日本| av中文字幕不卡| 中文字幕色av一区二区三区| 国产在线精品视频| 国产欧美一区二区三区鸳鸯浴 | 欧美日韩国产高清一区二区| 亚洲成人在线免费| 欧美成人性福生活免费看| 亚洲欧美一区二区在线观看| 亚洲九九爱视频| 色94色欧美sute亚洲线路一久| 国产校园另类小说区| 国产精品一二三四| 曰韩精品一区二区| 日韩一区国产二区欧美三区| 国产一区二区三区日韩| 久久精品一区二区三区不卡| 97国产一区二区| 午夜久久久影院| 欧美一区二区三区视频免费| 国产一区二区三区黄视频| 亚洲视频一区二区在线观看| 在线观看亚洲一区| 97国产一区二区| 日韩一区二区三区电影 | 精品美女一区二区| 国产伦理精品不卡| 中文字幕第一区第二区| 91精品国产综合久久久久久| 福利电影一区二区| 日韩二区三区在线观看| 亚洲国产岛国毛片在线| 日韩一区二区在线免费观看| 欧美又粗又大又爽| 成人毛片视频在线观看| 国产精一区二区三区| 夜夜嗨av一区二区三区| 久久久久久久精| 国产成人av自拍| 欧美国产精品专区| 日韩精品专区在线影院重磅| 欧美日韩激情一区二区三区| 欧美午夜理伦三级在线观看| 972aa.com艺术欧美| 国产99一区视频免费| 精彩视频一区二区三区| 五月天一区二区| 污片在线观看一区二区| 亚洲精品一二三| 欧美高清在线视频| 精品三级在线看| 精品免费日韩av| 国产精品久久久爽爽爽麻豆色哟哟 | 在线视频一区二区三区| 欧美性色黄大片| 日韩欧美一区二区视频| 亚洲精品在线免费观看视频| 91麻豆精品国产91久久久久久久久| 欧美亚洲尤物久久| 91黄色免费网站| 欧美午夜寂寞影院| 67194成人在线观看| 91精品综合久久久久久| 日韩一区二区免费在线观看| 日韩精品在线看片z| 国产亚洲欧美色| 亚洲曰韩产成在线| 精品一二线国产| 91在线播放网址| 精品国产一区二区在线观看| 久久久国产午夜精品| 亚洲欧美日韩国产综合| 日本午夜一区二区| eeuss鲁片一区二区三区在线看| 欧美在线综合视频| 国产精品免费视频一区| 日本女优在线视频一区二区| 国产精品性做久久久久久| 91电影在线观看| 国产欧美一区二区精品性色超碰| 日韩高清不卡在线| 色香蕉成人二区免费| 国产亚洲短视频| 美女视频一区在线观看| 欧美三级三级三级| 国产精品成人免费精品自在线观看| 日欧美一区二区| 色哟哟一区二区| 亚洲欧美日韩系列| 国产精品一级二级三级| 日韩一区二区在线播放| 亚洲妇熟xx妇色黄| 欧美性猛片xxxx免费看久爱| 亚洲国产精品av| 国产69精品久久99不卡| 国产日韩精品久久久| 国产精品原创巨作av| 日韩欧美国产综合一区| 久久精品国产一区二区三|