10 你在使用 LOGIN。SQL 文件时有哪些限制
它的限制就是你输入到其中的内容必须是 SQL 或 SQL*PLUS 的有效命令
11 DECODE 函数与过程语言中的 LOOP 功能是等价的 对不对
不对 它与 IF THEN 类似
12 如果你将查询重新定向到一个已经存在的文件中 你的输出将追加到这个文件 对不
对
不对 新文件将会覆盖原文件的内容
练习答案
4 利用在今天开始时的 PRODUCTS 表 写一个查询选择其中的所有数据并对记录的个数
进行汇总 要生成报表并且不得使用 SET FEEDBACK ON 命令
pute sum of count(*) on report
break on report
565
…………………………………………………………Page 566……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
select product_id; product_name; unit_cost; count(*)
from products
group by product_id; product_name; unit_cost;
5 假如今天是 1998 年 5 月 12 日星期一 写一个查询产生下边的输出
Today is Monday; May 12 1998
答
set heading off
select to_char(sysdate;" 〃Today is 〃Day; Month dd yyyy")
from dual;
6 试一下下边的语句
1 select *
2 from orders
3 where customer_id = "001"
4* order by customer_id;
不需要在缓冲区中重新输入这些语句 将 FROM 子句中的表改为 CUSTOMERS
在 ORDER BY 子句中加入 DESC
l2
c/orders/customer
现在你 DESC 加入到 ODRER BY 子句中
l4
append DESC
第 21 天 常见的 SQL 错误及解决方法
问题答案
1。 A user calls and says; 〃I can"t sign on to the database。 But everything was working fine
yesterday。 The error says invalid user/password。 Can you help me?〃 What steps should you take?
At first you would think to yourself; yeah sure; you just forgot your password。 But this error can
be returned if a front…end application cannot connect to the database。 However; if you know the
database is up and functional; just change the password by using the ALTER USER mand and
tell the user what the new password is。
2。 Why should tables have storage clauses and a tablespace destination?
In order for tables not to take the default settings for storage; you must include the storage clause。
Otherwise medium to large tables will fill up and take extents; causing slower performance。 They
also may run out of space; causing a halt to your work until the DBA can fix the space problem。
Exercise Answers
566
…………………………………………………………Page 567……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
1。 Suppose you are logged on to the database as SYSTEM; and you wish to drop a table called
HISTORY in your schema。 Your regular user ID is JSMITH。 What is the correct syntax to drop
this table?
Because you are signed on as SYSTEM; be sure to qualify the table by including the table owner。
If you do not specify the table owner; you could accidentally drop a table called HISTORY in the
SYSTEM schema; if it exists。
SQL》 DROP TABLE JSMITH。HISTORY;
2。 Correct the following error:
INPUT:
SQL》 select sysdate DATE
2 from dual;
OUTPUT:
select sysdate DATE
*
ERROR at line 1:
ORA…00923: FROM keyword not found where expected
DATE is a reserved word in Oracle SQL。 If you want to name a column heading DATE; then you
must use double quotation marks: 〃DATE〃。
3。 一个用户打电话说 “ 我不能登录数据库了 昨天还能呢 你能帮帮我吗 你该如
何做
首先 你要问他是否忘记了密码 但是这个错误也可能是因为前端无法联接到数据库
产生的 如果你可以确认数据据正常 那么你可以更改用户属性 并告诉他新的密码
4。 为什么表在存储子句中有表空间项
这是为了可以让表不使用默认的存储空间选项 否则如果表很大时 系统的性能就会
变慢 也可能会导致运行超时 系统挂死直到 DBA 修正了这个错误
练习答案
3。 如果你以 SYSTEM 身份登录了数据库 你想删除你的计划中的一个名字叫HISTORY
的表 如果你的用户 ID 是 JSMITH 那么正确的语法是怎样的
因为你是以 SYSTEM 身份登录的 所以要确认表的所有者对表的限制 如果你不是指
定的表的所有者 你也可以在 SYSTEM 计划中删除了这个表
4。 更正下边语句的错误
INPUT:
SQL》 select sysdate DATE
567
…………………………………………………………Page 568……………………………………………………………
SQL 21 日自学通(V1。0) 翻译人 笨猪
2 from dual;
OUTPUT:
select sysdate DATE
*
ERROR at line 1:
ORA…00923: FROM keyword not found where expected
DATE 是 ORACLE SQL 的保留字 如果你想把列句命名为 DATE 你应该在它的两边
加上单引号
568
………………………………………………………………………用户上传之内容结束……………………………………………………………………………………
小说推荐
- SQL语言艺术(PDF格式)
- -Page 1-SQLSSQQLL语言艺术内容介绍本书分为12章,每一章包含许多原则或准则,并通过举例的方式对原则进行解释说明。这些例子大多来自于实际案例,对九种SQL经典查询场景以及其性能影响讨论,非常便于实践,为你数据库应用维护人员阅读。资深 SQL 专家 Stéphane Faroult倾力打
- 最新章:第27章
- oracle从入门到精通(PDF格式)
- -Page 1-Oracle 从入门到精通-Page 2-资源来自网络,仅供学习 Oracle 从入门到精通一、SQL 8
- 最新章:第37章
- VB2008从入门到精通(PDF格式英文版)
- -Page 1(R)The eXperT’s Voice inBeginningVB 2008From Novice to ProfessionalChristian Gross-Page 2-Page 3-Beginning VB 2008From Novice to Professional■C
- 最新章:第214章
- C语言游戏编程从入门到精通(PDF格式)
- -Page 1-Page 2-Page 3-Page 4-Page 5-Page 6-Page 7-Page 8-Page 9-Page 10-Page 11-Page 12-Page 13-Page 14
- 最新章:第4章
- JMS简明教程(PDF格式)
- -Page 1-JMS1.1规范中文版卫建军2007‐11‐22-Page 2
- 最新章:第28章
- C语言实例教程(PDF格式)
- -Page 1-前 言Visual C+是开发运行于Windows 95和Windows NT环境下的Win32应用程序的可视化编程工具中最重要的成员之一,它为软件开发人员提供了完整的编辑、编译和调试工具和建立于Win32 API(ApplicationProgramming Interface)基
- 最新章:第143章
- 深入浅出MFC第2版(PDF格式)
- -Page 1-Page 2-山高月小山高月小 水落石出水落石出山高月小山高月小 水落石出水落石出-Page 3-深入淺出MFC(第版 使用Visual C 5.0 MFC 4.2)Dissecting MFC(Second Edition Using Visual C 5.0 MFC 4.2)侯俊
- 最新章:第309章
- 软件工程实践者的思想(PDF格式)
- -Page 1-大 道 至 简—软件工程实践者的思想周爱民(Aimingoo 著-Page 2-序2004 年 11 月初爱民(Aimingoo)第一次把他的书稿给我,我翻看了一下,第一反应讲的是感想。这不错,在技
- 最新章:第26章
- 电子电路大全(PDF格式)
- -Page 1-电力生产人员技能培训电路基础部分电路基础部分电电路路基基础础部部分分-Page 2-一、电路的基本概念和基本定律-Page 3-考试点1o 1、掌握电阻、独立电压源、独立电流源、11受控源、电容、电感、耦合电感、理想变压器诸元件的定义、性质2o 2、掌握电流、电压参考方向的概念223
- 最新章:第353章