Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1

    Unanswered: Creating Tables and Data From Text Files

    I've picked up a basic SQL book from Amazon to help me understand ANSI SQL. The book has a site where I'm suggested to download a sample database so that I may follow along and execute the explained lessons on. My problem is after I create the database:

    Code:
    CREATE DATABASE tysql OWNER carlos;
    CREATE DATABASE
    
    COMMENT ON DATABASE tysql IS 'Teach Yourself SQL';
    COMMENT
    Now I've downloaded the ZIP archive and extracted two files I've attached below which were specified for my particular RDBMS (PostgreSQL) that I'm using. My question is how to use the two files to CREATE my tables and INSERT my row data?
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2003
    Posts
    2,934
    Provided Answers: 12
    As those statements are for PostgreSQL:

    Connect to the newly created database using psql, then run those files using the \i command from psql

    Code:
    c:\> psql tysql carlos
    psql (9.1.1)
    Type "help" for help.
    
    tysql=>\i create.txt
    .... several messages ....
    tysql=>\i populate.txt
    For more details on the commands available in psql use "help" or simply read through the manual:
    http://www.postgresql.org/docs/curre.../app-psql.html

  3. #3
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1
    Thanks Shammat! Worked perfect.

  4. #4
    Join Date
    Nov 2003
    Posts
    2,934
    Provided Answers: 12
    Please post to the PostgreSQL forum the next time. The client tools (like psql) are highly DBMS specific and the ANSI SQL forum is not the right place for this.

  5. #5
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1
    I agree and apologize. I assumed since it was a ANSI SQL book and the files were *.txt, it would be ANSI SQL statements to CREATE / UPDATE my new database. Now I realized the commands were specific to my DBMS client (psql).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •