sqlplus

How to get the employees with their managers

半城伤御伤魂 提交于 2019-12-03 12:06:24
问题 This is what I want the output to look like: Employee Emp# Manager Mgr# BLAKE 7698 KING 7839 CLARK 7782 KING 7839 JONES 7566 KING 7839 MARTIN 7654 BLAKE 7698 ALLEN 7499 BLAKE 7698 TURNER 7844 BLAKE 7698 JAMES 7900 BLAKE 7698 WARD 7521 BLAKE 7698 FORD 7902 JONES 7566 SMITH 7369 FORD 7902 SCOTT 7788 JONES 7566 ADAMS 7876 SCOTT 7788 MILLER 7934 CLARK 7782 Here's what I got: SQL> SELECT ename, empno, (SELECT ename FROM EMP WHERE empno = mgr)AS MANAGER, mgr from emp order by empno; ENAME EMPNO

Connect to Oracle DB using sqlplus

前提是你 提交于 2019-12-03 11:55:31
I am using below command in Unix environment to connect to Oracle database: sqlplus test/test@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname.com )(PORT=1521)))(CONNECT_DATA=(SID=mysid))' But I am getting below error: Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus statements. Usage 1: sqlplus -H | -V -H Displays the SQL*Plus version and the usage help. -V Displays the SQL*Plus version. Usage 2: sqlplus [ [<option>] [{logon | /nolog}] [<start>] ] <option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S] Please help me where I am doing mistake in using the command.

executing a .sql file in sql plus terminal

↘锁芯ラ 提交于 2019-12-03 10:47:47
问题 I have written couple of sql scripts in a text file and saved them with a .sql extension. I want to execute these scripts in the sql plus terminal without having to manually type the standalone sql scripts, but i'm struggling with it. If someone could list out the steps involved I would be very grateful. I could copy and paste those scripts in the terminal but that is not what I am looking at, I want to see if there is a way to provide the path to the scripts in the sql plus editor. 回答1: If

“set -o noglob” in bash shell script

安稳与你 提交于 2019-12-03 09:01:05
I would usually write SQL statements inline in a Bash shell script to be executed in SQLPlus as- #! /bin/sh sqlplus user/pwd@dbname<<EOF insert into dummy1 select * from dummy2; commit; exit; EOF This would work just fine and will insert rows into dummy1 when executed. A colleague of mine came to me the other day with a script like below (simplified) #! /bin/sh sqlvar="insert into dummy1 select * from dummy2;commit;" echo $sqlvar|sqlplus user/pwd@dbname The issue with this is when executed the variable sqlvar expands the * to be all the files in the current directory and would eventually error

What username & password should be entered when connecting to SQL*Plus after installing Oracle 11g?

允我心安 提交于 2019-12-03 08:49:20
I have installed Oracle 11g on Windows 7 When I start sqlplus, it ask me for a username and password Can anybody tell me what username needs to be inserted and when I try to type in any password, it doesn't allow me to type a single letter. Is there a reason why? If you've forgotten the password for any user then you can reset by logging in as SYS: sqlplus / as sysdba And then: alter user <username> identified by <password>; If you've forgotten which users you have then you can run: select username from all_users; If you have only recently created the database it would be worthwhile

SqlPlus SP2-0734: Error

扶醉桌前 提交于 2019-12-03 08:38:02
问题 I am new to using SqlPlus but not new to using SQL, and I get the following error after writing this in my editor and attempting to run the script that I wrote. All of this appears to be valid and works on sql fiddle... I am not sure what the issue is. Any ideas?? None of the files I create seem to work.... SQL> start sales.sq; which contains 1 create table salesreps 2 (empl_num number(3,0) primary key, 3 name varchar2(15) not null, 4 age number(3,0), 5 rep_office number(2,0), 6 title

Preventing sqlplus truncation of column names, without individual column formatting

吃可爱长大的小学妹 提交于 2019-12-03 07:36:25
By default sqlplus truncates column names to the length of the underlying data type. Many of the column names in our database are prefixed by the table name, and therefore look identical when truncated. I need to specify select * queries to remote DBAs in a locked down production environment, and drag back spooled results for diagnosis. There are too many columns to specify individual column formatting. Does sqlplus offer any option to uniformly defeat column name truncation? (I am using SET MARKUP HTML ON, though I could use some other modality, csv, etc. as long as it yields unabbreviated

How to prettify the output coming from the SELECT query in command prompt?

风格不统一 提交于 2019-12-03 07:00:59
I ran the simple select query in the command prompt,but the output rows are not coming in a single line. See below: SQL> set pagesize 2000 SQL> select * from xtern_empl_rpt ; EMP LAST_NAME --- -------------------------------------------------- FIRST_NAME SSN -------------------------------------------------- --------- EMAIL_ADDR -------------------------------------------------------------------------------- YEARS_OF_SERVICE ---------------- 001 Hutt Jabba 896743856 jabba@thecompany.com 18 002 Simpson Homer 382947382 homer@thecompany.com 20 003 Kent Clark 082736194 superman@thecompany.com 5

executing a function in sql plus

喜你入骨 提交于 2019-12-03 06:38:27
问题 I created a function in oracle that inserts records in specific tables and return an output according to what occurs within the function. e.g (ins_rec return number) How do I call this function and see its output in sql plus 回答1: declare x number; begin x := myfunc(myargs); end; Alternatively: select myfunc(myargs) from dual; 回答2: One option would be: SET SERVEROUTPUT ON EXEC DBMS_OUTPUT.PUT_LINE(your_fn_name(your_fn_arguments)); 回答3: As another answer already said, call select myfunc(:y)

want to run multiple SQL script file in one go with in SQLPLUS

六月ゝ 毕业季﹏ 提交于 2019-12-03 06:34:28
I have to run multiple SQL script file in one go. Like every time i have to write command in SQLPLUS SQL>@d:\a.txt SQL>@d:\a2.txt SQL>@d:\a3.txt SQL>@d:\a4.txt is there any way put all file in one folder & run all script file in one go without missing any single file like @d:\final.txt or @d\final.bat There is no single SQL*Plus command to do that, but you can create a single script that calls all the others: Put the following into a batch file @echo off echo.>"%~dp0all.sql" for %%i in ("%~dp0"*.sql) do echo @"%%~fi" >> "%~dp0all.sql" When you run that batch file it will create a new script