我必须为我的数据库类使用 SQLPLUS,我们的第一个作业是简单的保存。
我按照说明进行操作..(我正在使用 PuTTY 访问 sqlplus)
“在本练习中使用以下 SQL 命令,并尝试使用 SAVE 和 SPOOL 命令将 SQL 命令和输出保存到外部文件。
select table_name from all_tables where owner='UNIVERSITY';
select * from university.faculty;
select * from university.clubs;
对于本实验,请执行以下操作:
At the SQL> prompt, type Save test.sql
(or save test.sql replace
if the file already exists) then hit enter; then type any SQL commands, the commands will be saved to the test.sql file. Later you can use the START command to run the saved SQL commands. E.g.:
SQL> start test.sql
At the SQL> prompt, type spool output.txt
then enter; then type any SQL commands; when finished type 'spool off'; the commands and results will be saved to file output.txt. The file will be overwritten if used in the spool command again. Turn in file test.sql
and output.txt
in the dropbox on D2L by Monday before class."
(显然寻求帮助并不违反规则,因为说明已经在那里了..我只是不明白它们或者它们是错误的)
当我输入 SAVE test.sql 时,我产生=>“没有什么可保存的”
当我在查询后输入 SAVE test.sql 时,它仅保存最后输入的查询。
如何让它保存我的所有查询而不是仅保存最后输入的查询?
如何让它保存我的所有查询而不是仅保存最后输入的查询?
SAVE 将 SQL*Plus 缓冲区的内容保存到文件中。缓冲区会被您编写的每个 SQL 语句替换,因此您只能获得最后一个命令。保存有一个append
将附加到文件的命令。
因此,首先创建您的文件。
save test.sql create
并在每个 SQL 脚本之后附加该文件。
select * from employees
/
save test.sql append;
select * from departments
/
save test.sql append;
等等
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)