sqlplus

Does SELECT DISTINCT imply a sort of the results

泪湿孤枕 提交于 2019-12-08 19:19:17
问题 Does including DISTINCT in a SELECT query imply that the resulting set should be sorted? I don't think it does, but I'm looking for a an authoritative answer (web link). I've got a query like this: Select Distinct foo From Bar In oracle, the results are distinct but are not in sorted order. In Jet/MS-Access there seems to be some extra work being done to ensure that the results are sort. I'm assuming that oracle is following the spec in this case and MS Access is going beyond. Also, is there

Execute SQL*Plus from PowerShell

让人想犯罪 __ 提交于 2019-12-08 07:27:18
问题 I got two files in C:\temp\SQL\alex.sql and in C:\temp\alex.ps1 . In C:\temp\SQL\alex.sql , that is simply select count(*) from user_tables; quit; In C:\temp\alex.ps1 , that is $cmd = "sqlplus"; $args = "user/password@server/sid @C:\temp\SQL\alex.sql"; &$cmd $args; I tried the command in Command Prompt sqlplus user/password@server/sid @C:\temp\SQL\alex.sql which executed perfectly! The SQL file is not executed at all, but SQL*Plus help is shown. What did I do wrong? Thanks! 回答1: I found the

Suppress the contents of the SQLplus command in UNIX?

烂漫一生 提交于 2019-12-08 06:43:07
问题 While connecting to db [ oracle] using sqlplus in Unix, I don't want to display the contents like: connected to... SQL>.... How would I remove these display entries? 回答1: Your probably looking for the option -silent (or just -s): > sqlplus -s username/password@database 来源: https://stackoverflow.com/questions/4655018/suppress-the-contents-of-the-sqlplus-command-in-unix

How do you assign the result of an expression to an SQL substitution variable?

白昼怎懂夜的黑 提交于 2019-12-08 05:46:02
问题 Can you evaluate an expression and assign the result to a substitution variable? In my case, I need to call an old script which contains a substitutions variable. I need to calculate a value for that variable before calling the script. I'm using Oracle SQL and SQL*Plus Here's the basic problem: def this_num = 2+2 @old_script Inside old_script.sql select '&this_num' from dual; -- Probably shouldn't change this Yields: '2+2' Is there a way to force evaluation so that the substitution variable

Cannot access oracle using sqlplus from another machine on the LAN

主宰稳场 提交于 2019-12-08 04:26:46
问题 I have Oracle running on one machine of the LAN. I can connect to the DB with sqlplus when I issue: sqlplus myuser/mypass@localhost:1521/orcl This works fine. On another machine from the LAN, I have installed oracle instant client (basic + sdk + sqlplus). sqlplus myuser/mypass@oracle_server:1521/orcl SQL*Plus: Release 11.2.0.3.0 Production on Sat Feb 25 09:10:41 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. ERROR: ORA-12543: TNS:destination host unreachable Enter user-name:

Export from sql to excel

我与影子孤独终老i 提交于 2019-12-08 00:52:17
问题 I run a query using sqlplus command line interface. The query will fetch some 30 million records. I need to export the result to either csv or xls format. Can anyone let me know if this is possible? Any help is much appreciated. Thanks in advance. 回答1: Try spool myresults.csv before your select statement, which Excel can easily open. EDIT Like this: SET UNDERLINE OFF SET COLSEP ',' --That's the separator used by excel later to parse the data to columns SET LINES 100 PAGES 100 SET FEEDBACK off

Pass Parameters from a batch file to sqlplus script

时光总嘲笑我的痴心妄想 提交于 2019-12-08 00:15:01
问题 I am trying to get one file with my user name and passwords for some scripts that I run every day. I have several scripts working now using a batch file that has my user names and passwords. My Password Batch file looks like this. parms.bat Rem Oracle Db set odbUsername=myUserName set odbpassword=myPassword My other scripts call that batch file and get the information ok. I have a couple sql scripts that I also need to use these usernames and passwords. I can't seem to get them to work. But I

redirect plsql error message to a log file when executing it in sqlplus

匆匆过客 提交于 2019-12-07 16:48:39
问题 Need a way to redirect PL/SQL program error message to a log file when executing it in sqlplus. Say the PL/SQL program is named send_2012.sql and it has the following exception block EXCEPTION WHEN NO_DATA_FOUND THEN var_err := 'Data not found. '; WHEN OTHERS THEN var_err := 'Error in ' || $$plsql_unit || ' | ' || SQLERRM || ' | ' || 'Details: ' || DBMS_UTILITY.format_error_backtrace; END; To run the PL/SQL program in a KornShell (ksh) script, I have: sqlplus some_username/'some_password'

Get IP addresses of established connections to Oracle 11

ぐ巨炮叔叔 提交于 2019-12-07 08:00:27
问题 During development I found that database have large number of lived connections by: SELECT username, COUNT(*) FROM v$session GROUP BY username; In order to find who actually hold connection I want to get a list of IP addresses. During general web search and reading official docs I build query: SELECT username, seconds_in_wait, machine, port, terminal, program, module, service_name FROM v$session WHERE type = 'USER'; where machine is most important part of select . But unfortunately machine

Oracle not available ora-01034

安稳与你 提交于 2019-12-07 07:28:56
问题 I am trying to create to connect with oracle sqlplus. When I login with: User: sys as sysdba Pass: It says Connected to an idle instance. And when I try to create a table, it gives the error ORA-01034: Oracle not available Process ID: 0 Session ID: 0 Serial number: 0 Why is it not creating the table? 回答1: First - and most importantly: Only use the SYS account for DBA work. Never use it for "regular" work (e.g. creating tables) - use a dedicated regular user account for that. Secondly: "