Notas de Luis

Notas Oracle

Corta y pega para empezar

  SET ECHO      OFF
  SET FEEDBACK  OFF
  SET HEADING   ON
  SET LINESIZE  300
  SET PAUSE     OFF
  SET PAGESIZE  0
  SET PAGESIZE  50000
  SET TERM      OFF
  SET TRIMOUT   ON
  SET TRIMSPOOL ON
  SET VERIFY    OFF
  SET WRAP      off
  alter session set current_schema = ctmuser;
  SET ECHO      ON

Ver version del servidor

  select * from v$version;

Ver la configuración de encoding (NLS)

  COL PARAMETER FOR A30;
  COL DATABASE  FOR A30;
  select * from v$nls_parameters order by parameter;
  SELECT PARAMETER, VALUE FROM NLS_DATABASE_PARAMETERS ORDER BY 1;

Fichero de configuracion

El fichero de configuracion se llama login.sql , y debe estar en el directorio actual o en uno de los directorios indicados en la variable de entorno SQLPATH .

Ver usuarios:

  select distinct owner from all_all_tables order by owner;

Ver tablas:

  select table_name from all_all_tables where owner = 'CTMUSER' order by
  table_name;
  
  select owner,table_name from all_all_tables order by owner,table_name;
  
  DESCRIBE ctmuser.cms_jobdef;

Settings

  COLSEP { |text}
     The text to be printed between SELECTed columns normally a space.
  ECHO {OFF|ON}
     Display commands as they are executed
  HEA[DING] {OFF|ON}
     print column headings
  LIN[ESIZE] {150|n}
     Width of a line (before wrapping to the next line)
     Earlier versions default to 80, oracle 9 to 150
  PAGESIZE n
     Longitud de la pagina en lineas.
     En cada pagina pone cabeceras.
     Es util para que las cabeceras aparezcan solo una vez.
  RECSEP {WR[APPED]|EA[CH]|OFF}
     Print a single line of the RECSEPCHAR between each record.
     WRAPPED = print only for wrapped lines
     EACH=print for every row
  RECSEPCHAR {_|c}
     Define the RECSEPCHAR character, default= ' '
  WRA[P] {OFF|ON}
     Controls whether to truncate or wrap the display of long lines.
     OFF = truncate
     ON = wrap to the next line
     The COLUMN command (WRAPPED and TRUNCATED clause)
     can override this for specific columns.

Limitar el tamano de una columna en el select

  COL jobname FORMAT A15;
  column fee format 999999999.99

SQL*Plus command reference

  @ ('at' sign)
  :Runs the SQL*PLus statements in the specified script. The script can be
  called from the local file system or from a web server.
  @ @ (double 'at' sign without space)
  :Runs a script. This command is similar to the @ ('at' sign) command. It is
  useful for running nested scripts because it looks for the specified script
  in the same path as the script from which it was called.
  
  / (slash)
    Executes the SQL command or PL/SQL block.
  ACCEPT
    Reads a line of input and stores it in a given user variable.
  APPEND
    Adds specified text to the end of the current line in the buffer.
  ARCHIVE LOG
    Starts or stops the automatic archiving of online redo log files, manually
    (explicitly) archives specified redo log files, or displays information about
    redo log files.
  ATTRIBUTE
    Specifies display characteristics for a given attribute of an Object Type
    column, and lists the current display characteristics for a single
    attribute or all attributes.
  BREAK
    Specifies where and how formatting will change in a report, or lists the
    current break definition.
  BTITLE
    Places and formats a specified title at the bottom of each report page, or
    lists the current BTITLE definition.
  CHANGE
    Changes text on the current line in the buffer.
  CLEAR
    Resets or erases the current clause or setting for the specified option,
    such as BREAKS or COLUMNS.
  COLUMN
    Specifies display characteristics for a given column, or lists the current
    display characteristics for a single column or for all columns.
  COMPUTE
    Calculates and prints summary lines, using various standard computations, on
    subsets of selected rows, or lists all COMPUTE definitions.
  CONNECT
    Connects a given user to Oracle.
  COPY
    Copies results from a query to a table in a local or remote database.
  DEFINE
    Specifies a user variable and assigns it a CHAR value, or lists the value
    and variable type of a single variable or all variables.
  DEL
    Deletes one or more lines of the buffer.
  DESCRIBE
    Lists the column definitions for the specified table, view, or synonym or
    the specifications for the specified function or procedure.
  DISCONNECT
    Commits pending changes to the database and logs the current user off
    Oracle, but does not exit SQL*Plus.
  EDIT
    Invokes a host operating system text editor on the contents of the specified
    file or on the contents of the buffer.
  EXECUTE
    Executes a single PL/SQL statement.
  EXIT
    Terminates SQL*Plus and returns control to the operating system.
  GET
    Loads a host operating system file into the SQL buffer.
  HELP
    Accesses the SQL*Plus help system.
  HOST
    Executes a host operating system command without leaving SQL*Plus.
  INPUT
    Adds one or more new lines after the current line in the buffer.
  LIST
    Lists one or more lines of the SQL buffer.
  PASSWORD
    Allows a password to be changed without echoing the password on an input
    device.
  PAUSE
    Displays the specified text, then waits for the user to press [Return].
  PRINT
    Displays the current value of a bind variable.
  PROMPT
    Sends the specified message to the user's screen.
  QUIT
    Terminates SQL*Plus and returns control to the operating system. QUIT is
    identical to EXIT.
  RECOVER
    Performs media recovery on one or more tablespaces, one or more datafiles,
    or the entire database.
  REMARK
    Begins a comment in a script.
  REPFOOTER
    Places and formats a specified report footer at the bottom of each report,
    or lists the current REPFOOTER definition.
  REPHEADER
    Places and formats a specified report header at the top of each report, or
    lists the current REPHEADER definition.
  RUN
    Lists and executes the SQL command or PL/SQL block currently stored in the
    SQL buffer.
  SAVE
    Saves the contents of the SQL buffer in a host operating system file (a
    script).
  SET
    Sets a system variable to alter the SQL*Plus environment for your current
    session.
  SHOW
    Shows the value of a SQL*Plus system variable or the current SQL*Plus
    environment.
  SHUTDOWN
    Shuts down a currently running Oracle instance.
  SPOOL
    Stores query results in an operating system file and, optionally, sends the
    file to a printer.
  START
    Executes the contents of the specified script. The script can only be called
    from a url.
  STARTUP
    Starts an Oracle instance and optionally mounts and opens a database.
  STORE
    Saves attributes of the current SQL*Plus environment in a host operating
    system file (a script).
  TIMING
    Records timing data for an elapsed period of time, lists the current timer's
    title and timing data, or lists the number of active timers.
  TTITLE
    Places and formats a specified title at the top of each report page, or
    lists the current TTITLE definition.
  UNDEFINE
    Deletes one or more user variables that you defined either explicitly (with
    the DEFINE command) or implicitly (with an argument to the START command).
  VARIABLE
    Declares a bind variable that can be referenced in PL/SQL.
  WHENEVER OSERROR
    Performs the specified action Exits SQL*Plus if an operating system command
    generates an error.
  WHENEVER SQLERROR
    Performs the specified action Exits SQL*Plus if a SQL command or PL/SQL
    block generates an error.
computing/databases/oracle.txt · Última modificación: por alfabeto