7 Replies Latest reply: Nov 20, 2012 11:54 AM by 969949 RSS

    plz solve this...

    969949
      not able to print properly.....
      SQL> conn scott/scottpw
      Connected.
      SQL> select * from user_constraints;
      
      OWNER                          CONSTRAINT_NAME                C TABLE_NAME                     SEARCH_CONDITION                                                                 R_OWNER                        R_CONSTRAINT_NAME              DELETE_RU STATUS   DEFERRABLE     DEFERRED  VALIDATED     GENERATED      BAD RELY LAST_CHAN INDEX_OWNER                    INDEX_NAME                     INVALID VIEW_RELATED
      ------------------------------ ------------------------------ - ------------------------------ -------------------------------------------------------------------------------- ------------------------------ ------------------------------ --------- -------- -------------- --------- ------------- -------------- --- ---- --------- ------------------------------ ------------------------------ ------- --------------
      SCOTT                          FK_DEPTNO                      R EMP                                                                                                     SCOTT                          PK_DEPT                        NO ACTION ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED     USER NAME       30-MAR-10
      SCOTT                          PK_EMP                         P EMP                                                                                                                                                                     ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED     USER NAME            30-MAR-10 SCOTT                     PK_EMP
      SCOTT                          PK_DEPT                        P DEPT                                                                                                                                                                    ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED     USER NAME            30-MAR-10 SCOTT                     PK_DEPT
        • 1. Re: plz solve this...
          Hoek
          Define 'print properly', please....


          {message:id=9360002}
          http://tkyte.blogspot.nl/2005/06/how-to-ask-questions.html
          • 2. Re: plz solve this...
            SomeoneElse
            SQL> set tab off
            • 3. Re: plz solve this...
              969949
              thnx SomeoneElse..... 1 another question how to remove those extra "-" which is in between column name and column values.
              • 4. Re: plz solve this...
                Frank Kulash
                Hi,
                555420 wrote:
                thnx SomeoneElse..... 1 another question how to remove those extra "-" which is in between column name and column values.
                SET   UNDERLINE   OFF
                tells SQL*Plus not to print a row separating the column headers from the first row of data.
                You can shorten it to
                SET   UND         OFF
                • 5. Re: plz solve this...
                  969949
                  hi Frank..... I want those "-" but want to remove EXTRA "-".

                  e.g instead of this o/p
                  OWNER                          CONSTRAINT_NAME               
                  ------------------------------ ------------------------------
                  SCOTT                          FK_DEPTNO                     
                  SCOTT                          PK_EMP                        
                  SCOTT                          PK_DEPT                       
                  I want
                  OWNER CONSTRAINT_NAME               
                  ----- ---------------
                  SCOTT FK_DEPTNO                     
                  SCOTT PK_EMP                        
                  SCOTT PK_DEPT        
                  • 6. Re: plz solve this...
                    JustinCave
                    Then you'll need to tell SQL*Plus how wide you want each column to be. For example
                    SQL> column owner format a5
                    tells Oracle to display the OWNER column as a 5 character string (the USER_CONSTRAINTS view allows OWNER to be up to 30 characters). You would need to do the same thing for every column.

                    Assuming you are relatively new to Oracle, though, are you sure that you really want to be using SQL*Plus in the first place? If you're a relatively new user that is concerned about the presentation of data, I would tend to suspect that you really ought to be using SQL Developer instead. SQL Developer is a GUI that, generally, provides a much more pleasing default presentation of the data than SQL*Plus does.

                    Justin
                    • 7. Re: plz solve this...
                      Solomon Yakobson
                      555420 wrote:
                      but want to remove EXTRA "-".
                      Then use:
                      COLUMN OWNER FORMAT A5
                      COLUMN CONSTRAINT_NAME FORMAT A15
                      However, if owner name is longer than 5 characters or constraint name is longer than 15 characters it will be split into multiple lines:
                      SQL> COLUMN OWNER FORMAT A5
                      SQL> COLUMN CONSTRAINT_NAME FORMAT A15
                      SQL> select  owner,
                        2          constraint_name
                        3    from user_constraints
                        4  /
                      
                      
                      OWNER CONSTRAINT_NAME
                      ----- ---------------
                      SCOTT FK_DEPTNO
                      SCOTT EMP2_PK
                      SCOTT TBL_PK
                      SCOTT PK_EMP
                      SCOTT PK_DEPT
                      
                      SQL> alter table emp2
                        2    add constraint longer_than_fifteen_characters
                        3      check(sal > 0)
                        4  /
                      
                      Table altered.
                      
                      SQL> select  owner,
                        2          constraint_name
                        3    from user_constraints
                        4  /
                      
                      
                      OWNER CONSTRAINT_NAME
                      ----- ---------------
                      SCOTT FK_DEPTNO
                      SCOTT EMP2_PK
                      SCOTT TBL_PK
                      SCOTT PK_EMP
                      SCOTT PK_DEPT
                      SCOTT LONGER_THAN_FIF
                            TEEN_CHARACTERS
                      
                      
                      6 rows selected.
                      
                      SQL> 
                      SY.