sqlplus

How do I prompt input for database on command line?

自闭症网瘾萝莉.ら 提交于 2019-12-13 08:17:24
问题 I need to prompt ENTER DATABASE NAME. But It doesn't and it still connects. What database does it connects to? It says "CONNECTED TO " Here's the batch code. @echo off sqlplus &username/&password@&db ECHO About to exit. timeout t/ 30 :pause 回答1: Ampersand ( & ) is used for SQL*Plus substitution variables. You are supplying it on the Windows command line, where it means something else; when you exit from the client you'll see something like: 'username' is not recognized as an internal or

Buffer too small for CLOB to CHAR or BLOB to RAW conversion

血红的双手。 提交于 2019-12-13 04:45:12
问题 I have written this script and now get an error that "Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 68579, maximum: 4000)". How can I fix this? set serveroutput on; Declare match_count Number :=0; v_from NUMBER(19) :=2019030651; CURSOR s is (SELECT owner, table_name, column_name FROM ALL_TAB_COLUMNS where owner LIKE 'SOMETHING_%' ); begin for t in s LOOP begin EXECUTE IMMEDIATE 'SELECT count(*) FROM '||t.owner || '.' || t.table_name|| ' WHERE '||t.column_name||' LIKE :1

Oracle where exists clause not working on SQL Plus

ⅰ亾dé卋堺 提交于 2019-12-13 04:22:33
问题 I have a query with a "WHERE EXISTS()" clause. When I execute it on SQL Developer it returns rows, but when I execute it in SQL Plus it doesn't. Any one has a clue why this is happening? Thanks in advance. Regards, Joao 回答1: If the query returns rows into one database session (say, created by SQL Developer) and doesn't return any rows in the other (say, created by SQL Plus) it means these sessions are different. The difference may be: database connected connected user current schema NLS

Why do I get ORA-12514 with easy connect but not with TNS?

做~自己de王妃 提交于 2019-12-13 03:36:29
问题 I can connect successfully to my database with a TNS-style connect descriptor: connect <user>/<pass>@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=<host>)(Port=<port>))(CONNECT_DATA=(SID=<sid>))); But when I try to connect like this: connect <user>/<pass>@<host>:<port>/<sid>; I get ORA-12514: TNS:listener does not currently know of service requested in connect descriptor . Why does the fist command work but the second does not? 回答1: SID and service name are not the same thing. In your working

Oracle select not returning all columns under sqlplus

此生再无相见时 提交于 2019-12-13 03:35:37
问题 I have the below SQL select : select TST_CODE ||'|'||UTI_CODE ||'|'||TST_NAME ||'|'||TST_NAME_REDUIT ||'|'||TST_GROUP ||'|'||TST_MET ||'|'||TST_MET_CODE ||'|'||TST_MET_FAMILY ||'|'||TST_MET_CALCUL ||'|'||TNS_STATUS_PAR_NM2 ||'|'||TNS_STATUS_PART_NM1 ||'|'||TNS_STATUS_PART_N ||'|'||STR_CODE ||'|'||FOUR_CODE ||'|'||TST_SIREN ||'|'||MEMO_ASC ||'|'||NAV_FICID from TEST_TABLE; When I run it in SQL Developer it returns my all the columns of the table. But when I put the same request in an SQL file,

How can I create a batch file for SQLPlus?

こ雲淡風輕ζ 提交于 2019-12-13 02:08:11
问题 I need to create a batch file, i.e., batch.bat . When we execute this file: It will open SQLPlus It will call a file called file1.sql . file1.sql contains the creation and insertion scripts for a particular user. I have file.sql , but what I need to know is, how do I create a batch file to perform this function? 回答1: A little test script (stored in file named test.sql ): select 1 from dual; exit; ... and to execute it: sqlplus user/password @test.sql 来源: https://stackoverflow.com/questions

Select Database details and table names in iSQL plus

。_饼干妹妹 提交于 2019-12-13 00:44:00
问题 I used the answer of the question found here to get the database name using this command select ora_database_name from dual; . and below is a screen shot of the result. But how to get the details of this database found in the screenshot and its list of tables? 回答1: You can find most details of the database and the client using the queries against metadata tables or USERENV variables. For example: select * from global_name; -- will give you the name select * from v$version; -- will give you

Can I use UTILS in Oracle?

耗尽温柔 提交于 2019-12-12 21:26:50
问题 I want to ask if I can use the following in Oracle: UTILS.CONVERT_TO_VARCHAR2 for instance: SELECT insertData, UTILS.CONVERT_TO_VARCHAR2(insertData,10,p_style=>104) insert_short FROM students If it is not possible to use UTILS package, so which alternative I can use? 回答1: Basically, yes. My guess is that you've taken some SQL Server T-SQL and run it through the Oracle SQL Developer Translator ( Tools - Migration - Scratch Editor ) and this is what came out the other side. UTILS is a package

Suppressing passwd when calling sqlplus from shell script

末鹿安然 提交于 2019-12-12 20:50:43
问题 My script calls sqlplus in the standard format: sqlplus $USER/$PASSWD@$DBNAME Obviously, this is not very safe because ps -ef displays the entire command, including the passwd. How can I invoke sqlplus without a manual prompt but still hide the passwd? Thanks 回答1: What you need is a different method of authentication, such as the Oracle Wallet. Here's a walk-through in the documentation. http://docs.oracle.com/cd/E11882_01/network.112/e16543/authentication.htm#CBHGEBEI 回答2: BAD: sqlplus $USER

Why this PL/SQL doesn't work?

爱⌒轻易说出口 提交于 2019-12-12 20:33:01
问题 Im trying to learn PL/SQL. I am struck with this code. Please notify me where im going wrong. I use Oracle 10g in a command line . declare grade char(1):='&v_grade'; app varchar(15); begin app:=case v_grade when 'a' then dbms_output.put_line('Excellent'); when 'b' then dbms_output.put_line('Good'); else dbms_output.put_line('Bad'); end case; dbms_output.put_line('Grade'||grade||' Appraisal:'||app); end; / It shows Enter value for v_grade: a old 2: grade char(1):='&v_grade'; new 2: grade char