这是我的 glogin.sql
set feedback on;
set linesize 9000
set colsep |
column titolo format a30
column anno format a20
column genere format a20
column formato format a20
column lingua format a20
--alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';
set serveroutput on;
set autocommit off;
set pagesize 100;
set long 20000;
set timing on;
alter session set cursor_sharing = 'EXACT'
select 'You are: '||upper(user) "Welcome to LINUX-ORACLE system" from dual
union all select 'Logged into: '||upper(sys_context('userenv','db_name')) from dual
union all select 'Database Version: '||banner from v$version where rownum <= 2;
我有两个可插入数据库,名为“video”和“libri” 对于“video”数据库工作正常,但对于不同的数据库,视频数据库和“libri”数据库中存在的列“titolo”太大。 我的问题很简单:是否可以为同一列但在不同的数据库中设置不同的格式? 例如,a30 代表视频数据库,a10 代表图书馆数据库。
最佳答案
第一期
SQL> column col_width new_value col_width;
SQL*Plus命令,然后使用以下包含数据库名称作为条件的查询,并通过 column <col_name> format "a&col_width"
指定表中的相关列名称
SQL> select case when regexp_like(sys_context('userenv','db_name'),'LibRi','i') then
10
else 30
end as col_width
from dual; --> assuming you have only two different DB "else" is used directly.
COL_WIDTH
----------
2
SQL> column titolo format "a&col_width"
SQL> select titolo from mybooks where id=41471;
TITOLO
----------
MEMORIEDIU
NALADRA
关于oracle - Glogin.sql 用于可插入数据库或 Oracle 上的不同数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58401339/