楼主: easyfree

[精华] 培训: 001 Lesson 1-15 -- 2001/11/20最新补充: Lesson 14-15

[复制链接]
论坛徽章:
1
授权会员
日期:2005-10-30 17:05:33
21#
发表于 2001-11-13 15:22 | 只看该作者
To join tables together, you need a minimum of the number of join conditions summarized as the number of tables minus one. 最少的连接条件是连接表的个数-1(重点考试题)This rule may not apply if your table has a concatenated primary key, in which case more than one column is equired to uniquely identify each row. 当有组合的主键时,刚才的原则不适用
这句话我没有太了解,可以再解释一下吗,或者举一个例子,谢谢了。

使用道具 举报

回复
论坛徽章:
4
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33管理团队2006纪念徽章
日期:2006-04-16 22:44:45会员2006贡献徽章
日期:2006-04-17 13:46:34
22#
发表于 2001-11-13 16:04 | 只看该作者
斑竹同志,
在中文字符集下具体的char格式如何寻找?
是按中文的拼音排序来找的
我试过的,至于原因我也不大清楚

使用道具 举报

回复
论坛徽章:
4
ITPUB元老
日期:2005-02-28 12:57:00授权会员
日期:2005-10-30 17:05:33管理团队2006纪念徽章
日期:2006-04-16 22:44:45会员2006贡献徽章
日期:2006-04-17 13:46:34
23#
发表于 2001-11-13 16:26 | 只看该作者
另外
这句话我也有点难以理解
‘如果使用&&,SQLPLUS将记住使用了&&之后同名变量的值“
是什么意思,或请斑竹说得清楚一些

使用道具 举报

回复
论坛徽章:
1
管理团队2006纪念徽章
日期:2006-04-16 22:44:45
24#
发表于 2001-11-15 09:46 | 只看该作者
也有道理!

使用道具 举报

回复
论坛徽章:
25
ITPUB元老
日期:2005-02-28 12:57:00管理团队成员
日期:2011-05-07 01:45:082012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:18马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14
25#
 楼主| 发表于 2001-11-15 13:20 | 只看该作者
最初由 justforit 发布
[B]另外
这句话我也有点难以理解
‘如果使用&&,SQLPLUS将记住使用了&&之后同名变量的值“
是什么意思,或请斑竹说得清楚一些 [/B]



很简单, 比如
SQL> select &y+123+&y*10 from dual;
输入y的值: 2
输入y的值: 2
原值   1:select &y+123+&y*10 from dual
新值   1:select 2+123+2*10 from dual

2+123+2*10
----------
       145
注意: 同样是变量y, 但却需要输入两次同样的值,假如改为:
SQL> select &&y+123+&y*10 from dual;
输入y的值: 2
原值   1:select &&y+123+&y*10 from dual
新值   1:select 2+123+2*10 from dual

2+123+2*10
----------
       145
那么输入一次就可以了, 后面的变量y,sqlplus都会自动匹配前面你输入的值

这对你使用同一命令完成不同处理,而又需要反复用到某个自变量的时候很有用处

使用道具 举报

回复
论坛徽章:
25
ITPUB元老
日期:2005-02-28 12:57:00管理团队成员
日期:2011-05-07 01:45:082012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:18马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14
26#
 楼主| 发表于 2001-11-15 13:26 | 只看该作者
最初由 justforit 发布
[B]斑竹同志,
在中文字符集下具体的char格式如何寻找?
是按中文的拼音排序来找的
我试过的,至于原因我也不大清楚 [/B]


确实是拼音次序,和汉字编码的次序一样,是国标字库中的排列次序

使用道具 举报

回复
论坛徽章:
1
授权会员
日期:2005-10-30 17:05:33
27#
发表于 2001-11-15 13:27 | 只看该作者
Lesson 4

Table aliases can be up to 30 characters in length.    -8i中规定?

Tested 30 is still the limit even in 9i. Assume 8i is the same...

使用道具 举报

回复
论坛徽章:
0
28#
发表于 2001-11-15 17:41 | 只看该作者
请 教:为什么我下载的ORACLE 001官方教材中没有Multiple-Column Subqueries 一 节?在第6节中只说了SINGLE ROW SUBQUERIES 和MULTIPLE ROW SUBQUERIES。
请多指 教。

使用道具 举报

回复
论坛徽章:
25
ITPUB元老
日期:2005-02-28 12:57:00管理团队成员
日期:2011-05-07 01:45:082012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:18马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14
29#
 楼主| 发表于 2001-11-15 17:48 | 只看该作者

Lesson 11-13

[php]
Lession11        Manipulating Data

* You can place a subquery in the place of the table name, essentially the same way a view is used.
        For example, UPDATE (SELECT * FROM s_dept) SET id = 50 WHERE id = 60;
* Common errors that can occur during user input:
        1. Mandatory value missing for a NOT NULL column
        2. Duplicate value violates uniqueness constraint
        3. Foreign key constraint violated
        4. CHECK constraint violated
        5. Datatype mismatch
        6. Value too wide to fit in column
* The date also contains time information, the default time is midnight (00:00:00). If the RR format is set, the century may not be the current one.
* The SQL*Plus SET VERIFY command lists the substitution prior to executing the statement.
* For date and character values, the ampersand(& and the variable name are enclosed in single quotation marks.
* Do not prefix the SQL*Plus substitution parameter with the ampersand(& in the ACCEPT command.
* In general, use the primary key to identify a single row. -- 非主键条件可能引起多记录更新
* You can use the TRUNCATE command to quickly remove all rows from a table or cluster. Removing rows with the TRUNCATE command is faster than removing them with the DELETE command for the following reasons. The TRUNCATE command is a data definition language command and generates no rollback information. It will be covered in a later lesson. Truncating a table does not fire the table’s DELETE triggers. --TRUNCATE是比DELETE更快的全表删除的命令,但它是DCL命令,无法回滚,它也不会出发表级的DELETE TRIGGER
* If the referential integrity constraint contains the ON DELETE CASCADE option, then the selected row and its children are deleted from their respective tables.
* A transaction begins when the first executable SQL command is encountered and terminates when one of the following occurs:
        A COMMIT or ROLLBACK command is issued.
        A DDL command, such as CREATE, or DCL command is issued.
        Certain errors are detected, such as deadlocks.
        The user exits SQL*Plus.
        A machine fails or the system crashes.
* Implicit Transaction Processing
        Status                                 Circumstance
        Automatic commit         DDL command or DCL command is issued.
                                                Normal exit from SQL*Plus, without explicitly issuing COMMIT or ROLLBACK.
        Automatic rollback         Abnormal termination of SQL*Plus, or system failure.
* Data manipulation operations primarily affect the database buffer; therefore, the previous state of the data can be recovered.
* Other user cannot view the results of the data manipulation operations for the current user. Oracle7 institutes read consistency to ensure that each user sees data as it existed at the last commit.  -- 保持读一致性,因此只有本用户可以看到自己更改而未提交的数据
* Following a COMMIT, The locks on the affected rows are released; All savepoints are erased.
* If you create a second savepoint with the same name as an earlier savepoint, the earlier savepoint is deleted.
* Manually acquire locks on the database tables by executing a LOCK TABLE command, the SELECT command with the FOR UPDATE clause, or the SET TRANSACTION command with the READ ONLY option.
* The Oracle7 Server implements locks on data to provide data concurrency in the database. Those locks are released when certain events occur (such as a system failure) or the transaction is completed.
* The 'Roll' command are not save in SQL buffer, but the 'Rollback' saved
* An automatic rollback occurs when a system crashes.
-----------------------------------------------
Lession12        Altering Tables and Constraints

* RENAME、TRUNCATE、COMMENT都是DDL语句, 执行DDL命令, 发生autocommit,不论该语句是否成功(语法错误的情况除外). TRUNCATE also releases the storage space.
* ALTER TABLE ADD columns:  新增的列总是表中的最后一列 The new column becomes the last column.
* If a table already contains rows when a column is added, then all of the fields in the new column are initially NULL. You can define a NOT NULL column only if the table contains no rows because data cannot be specified for existing rows at the same time that the
column is added.
* Cannot drop or rename a column in the table (注意:8i中可以drop columns)
* A change to the default value of a column only affects subsequent insertions to the table.
* You can add, drop, enable, or disable a constraint, but you cannot modify its structure.
* If you enable a UNIQUE or PRIMARY KEY constraint, a UNIQUE or PRIMARY KEY index is automatically created.
* When use DROP or DISABLE constraints, you can use the CASCADE clause drop or disables dependent integrity constraints.
* DROP TABLE table [CASCADE CONSTRAINTS];  The CASCADE CONSTRAINTS option will also remove dependent referential integrity constraints.  Only the creator of the table or a user with the DROP ANY TABLE privilege can remove a table.
* You must be the owner of the object (table, view, sequence, or synonym) you rename.
* You can add a comment of up to 2000 bytes about a column, table, view, or snapshot by using the COMMENT command. The comment is stored in he data dictionary and can be viewed in one of the following data dictionary views in the COMMENTS column:
        ALL_COL_COMMENTS
        USER_COL_COMMENTS
        ALL_TAB_COMMENTS
        USER_TAB_COMMENTS

? Additional options for the above syntax are USING INDEX, EXCEPTIONS INTO, and ALL TRIGGERS clauses.
-----------------------------------------------
Lession13        Creating Sequences

* If the INCREMENT BY value is negative, the sequence will descend. Additionally, NOMAXVALUE then specifies a maximum value of -1 and NOMINVALUE sets a minimum value of -(10^26 ).
* ORDER | NOORDER options is only relevant with the Parallel Server option.
* If sequence values are cached, they will be lost if there is a system failure.
* Create Sequence 的缺省值:increament by 1 / start with 1 / nomaxvalue(10^27) / nominvalue(1) /  nocycle / nocache(20)
* Do not use the CYCLE option if the sequence is used to generate primary key values.
* You can also confirm the settings of the sequence by selecting from the data dictionary’s USER_SEQUENCES table.
* LAST_NUMBER column is the last number generated by the sequence if you do not use the CACHE option, which means that it is the value you acquire when you use a sequence.NEXTVAL expression. If you use the CACHE OPTION, LAST_NUMBER displays the next value after all the numbers in the cache are used.
* NEXTVAL must be used to generate a sequence number in the current user’s session before CURRVAL can be referenced.
* You can use NEXTVAL and CURRVAL in
        The SELECT list of a SELECT statement that is not part of a subquery.
        The SELECT list of a subquery in an INSERT statement.
        The VALUES clause of an INSERT statement.
        The SET clause of an UPDATE statement.
  You cannot use NEXTVAL and CURRVAL in
        A SELECT list of a view.
        A SELECT statement with the DISTINCT keyword.
        A SELECT statement with the GROUP BY, HAVING, or ORDER BY clauses.
        A subquery in a SELECT, DELETE, or UPDATE statement.
        A DEFAULT expression in a CREATE TABLE or ALTER TABLE command.
* 产生序列跳号的原因:
        If you roll back a command containing a sequence, the number is lost.
        If the sequence caches values in the memory, then those values are lost if the system crashes.
        Because the same sequence can be used for multiple tables. If this occurs, each table can contain gaps in the sequential numbers.
* Only if the sequence was created with NOCACHE, view the next available sequence value by querying the USER_SEQUENCES without incrementing it
* You must own or you have the ALTER privilege for the sequence in order to modify it.
* You must be the owner of the sequence or have the DROP ANY SEQUENCE privilege to remove it.
* 不能否在plsql中直接赋值给变量:a := sequence.NEXTVAL, 必须使用select sequence.NEXTVAL from dual;
* 在同一个session中,必须在使用NEXTVAL之后才能使用CURRVAL
-- end ---
[/php]

使用道具 举报

回复
论坛徽章:
0
30#
发表于 2001-11-20 15:17 | 只看该作者
坛主,整理这些资料花了不少时间吧,做坛主不容易!!

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表