sqlplus

How do I get SQL*Plus to create views / tables with a blank line in the middle of the create statement?

。_饼干妹妹 提交于 2019-12-20 18:09:27
问题 I wish to create some views using SQL*Plus via script, but seem to hit a problem if a developer has placed a blank line mid statement. The following statement works fine in TOAD / PL/SQL developer etc, but fails in SQL*Plus. (This is usually scripted, but entering it manually gives exactly the same error) Can anyone tell me why / how to stop it? CREATE VIEW bob AS SELECT * FROM DUAL; With SQL*Plus output SQL> CREATE VIEW bob 2 AS 3 SELECT * 4 SQL> FROM DUAL; SP2-0042: unknown command "FROM

oracle 多实例配置记录

北慕城南 提交于 2019-12-20 11:17:01
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> oracle在实际开发中,避免不了同一个数据库,有多个版本的情况,所以我们需要熟悉知道,数据库,与实例,表空间,用户,之间的关系 创建不同的实例,放置不同的数据库版本,是我们简单实用的做法 1.在安装好oracle 服务端后,会有一个默认数据库 orcl ,根据需要还原的数据库,在orcl这个实例创建相应的表空间,通过cmd,执行sqlplus / @orcl as sysdba, 命令进入orcl 实例,在sql> 做以下操作, --创建表空间 create tablespace XXX datafile 'E:\app\gf\product\11.2.0\dbhome_1\dbs\asset_data.dbf' size 1000M autoextend on next 100; create temporary tablespace XXXX tempfile 'E:\app\gf\product\11.2.0\dbhome_1\dbs\asset_data_temp.dbf' size 500M autoextend on next 100; 2.然后在orcl实例的表空间,创建对应的用户 --创建用户并指定表空间 create user asset identified by asset123

How to echo text during SQL script execution in SQLPLUS

风流意气都作罢 提交于 2019-12-20 11:08:04
问题 I have a batch file which runs a SQL script in sqlplus and sends the output to a log file: sqlplus user/pw < RowCount.sql > RowCount.log My log file contains this: Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production SQL> SQL> COUNT(*) ---------- 0 SQL> COUNT(*) ---------- 0 etc. but it's several thousand lines of output and therefore hard to determine which results belong to which statement. I would like to add some formatting to the output, so that I may discern

Unable to use Accept Command in Oracle

时间秒杀一切 提交于 2019-12-20 07:08:45
问题 The command prompt doesn't allow me to key in values. How should I solve this problem? 回答1: The SQL*Plus ACCEPT command accepts values from the user using SQL*Plus formats. To declare something as a CHAR(7) you would use a7 or to declare something as a NUMBER(4,0) you would use 9999 . SQL> accept stdnum char format 'a7' prompt 'Enter student number: ' Enter student number: abc SQL> accept year number format '9999' prompt 'Enter year: ' Enter year: 2017 The documentation defines the syntax (I

Why rlwrap echos “redundantly” what I type from the keyboard?

一曲冷凌霜 提交于 2019-12-20 04:57:07
问题 I am using the rlwrap utility under linux for command line editing while using sql*plus. Everything is fine except that the utility echoes every command I enter from the keyboard. For example suppose that I typed this statement in the prompt: SQL> select last_name from employees the same statement would be echoed again in the terminal making the output looks like: SQL> select last_name from employees select last_name from employees then when I complete the select statement on the next line,

CRON and SQLPLUS

自闭症网瘾萝莉.ら 提交于 2019-12-20 04:31:26
问题 I want to run a script, which contains some sqlplus commands, in cron. The problem is, that the sqlplus command won't be executed for some reason, when executed in cron. If I execute it by myself, the script runs fine. I've checked some forums, even the topics here on stackoverflow.com and found some tips regarding the correct setting of environment variables. But even after double checking this, the script doesn't work. Here is my script: echo $ORACLE_HOME|grep "oracle" > /dev/null if [ $? =

PL SQL trigger using raise_application_error thows error.

旧城冷巷雨未停 提交于 2019-12-20 04:16:42
问题 I have a few things of code I need help debugging but I feel that if I can get one of them running i'll be able to get the rest(oh how i hope). create or replace trigger minimumwage before insert or update on Employee for each row begin if :new.Wage < 7.25 then raise_application_error('-20000,Pay is below Texas minimum wage!'); end if; end; / I'm trying to do this on a table ran on my school's server through sqlplus if that helps. 回答1: When you're getting an error, it's always helpful to

Remove Unwanted/Extra Data in SQLPLUS

若如初见. 提交于 2019-12-20 04:15:55
问题 I am running a file via batch file Batch File: sqlplus admin/admin@SERVER @abc.sql > output.txt SQL File abc.sql: set PAGESIZE 1000 set LINESIZE 550 set echo off set head off set FEEDBACK OFF select * from S_ABC exit; Output.txt: Connected To: Oracle Database 11g................................ . . . DATA . . Disconnected from Oracle Database 11g ....... . . Please help me remove the extra data, in the starting and end of output.txt file. 回答1: -S seems to be what you're looking for; sqlplus

How best can I recreate an Oracle database?

筅森魡賤 提交于 2019-12-20 01:46:12
问题 Oracle 11gR2 (x86 Windows): I have a db with 250 tables with indexes and constraints. I need to re-create these tables, indexes and constraints in a new db and load the data. I need to know how to do the following in SQL Plus and/or SQL Developer, unless there's a magical utility that can automate all of this. Thanks in advance! Unload (export) all the data from the 250 tables. Create an sql script file containing the CREATE TABLE statements for the 250 tables. Create an sql script file

I want to pass a variable argument to external SQL file (PL/SQL with SQL*Plus)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 01:38:15
问题 I have search this forum and via google for an answer for my question, but I can't find a specific answer for my challenge. That is why I am asking it here to hope to receive an answer from one of you guys. I want to work with multiple SQL files, whereas one SQL file is the control file that executes the other SQL files with parameters. That file is called: startup.sql I have a table with all my values (don't mind the names of the columns, I changed them for my post). create table control ( S