Procedure documentationRedirecting Results to a File Locate this document in the navigation structure

 

You redirect the result of one or more SQLCLI commands to a <file>.

Prerequisites

You are logged on to a database.

More information: Logging on to a Database

Procedure

  1. Enter the following command:

    \o <file>

    Note Note

    Enter the full path of the file.

    End of the note.
  2. Enter the command whose result is to be redirected to the <file>.

    <command>

    To enter multiple commands in succession, press Enter after each command.

  3. To stop redirection to a file, enter \o.

Example

  1. Log on to the DEMODB database as user MONA with the password RED:

    sqlcli -d DEMODB -u MONA,RED

  2. Create the file c:\tmp\redirected.txt to which SQLCLI is to redirect the result:

    \o c:\tmp\redirected.txt

  3. Enter the following command:

    \ds

  4. Enter another command (SQL statement).

    select * from HOTEL.CUSTOMER

  5. Stop redirection to thefile.

    \o

    The redirected.txt file now has the following content:

    | Schema name | Owner name |

    | ----------- | -------------------------------- |

    | DBADMIN | DBADMIN |

    | DBM | DBM |

    | DOMAIN | DBADMIN |

    | HOTEL | MONA |

    | MONA | MONA |

    | OMS | DBADMIN |

    | SYSINFO | DBADMIN |

    | CNO | TITLE | FIRSTNAME | NAME | ZIP | ADDRESS|

    | ------ | ------- | ---------- | ---------- | ----- | -------|

    | 3200 | Company | ? | Datasoft | 90018 | 486 Maple Str.|

    | 3400 | Mrs | Mary | Griffith | 20005 | 3401 Elder Lane|

    | 3500 | Mr | Martin | Randolph | 60615 | 340 MAIN STREET, #7|

    | 3600 | Mrs | Sally | Smith | 75243 | 250 Curtis Street|

    | 3700 | Mr | Mike | Jackson | 45211 | 133 BROADWAY APT. 1|

    | 3900 | Mr | George | Howe | 75243 | 111 B Parkway, #23|

    | 4000 | Mr | Frank | Miller | 95054 | 27 5th Str., 76|

    | 4400 | Mr | Antony | Jenkins | 20903 | 55 A Parkway, #15|

    ...

More Information

Executing Commands