If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Creating Tables and Data From Text Files

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-05-11, 13:46
CarlosinFL CarlosinFL is offline
Registered User
 
Join Date: Oct 2010
Location: Orlando, FL
Posts: 184
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
File Type: txt create.txt (2.6 KB, 16 views)
File Type: txt populate.txt (7.0 KB, 13 views)
Reply With Quote
  #2 (permalink)  
Old 10-05-11, 14:06
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
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
Reply With Quote
  #3 (permalink)  
Old 10-05-11, 14:09
CarlosinFL CarlosinFL is offline
Registered User
 
Join Date: Oct 2010
Location: Orlando, FL
Posts: 184
Thanks Shammat! Worked perfect.
Reply With Quote
  #4 (permalink)  
Old 10-05-11, 14:34
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
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.
Reply With Quote
  #5 (permalink)  
Old 10-05-11, 14:36
CarlosinFL CarlosinFL is offline
Registered User
 
Join Date: Oct 2010
Location: Orlando, FL
Posts: 184
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).
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On