Docstoc

08

Document Sample
08 Powered By Docstoc
					              Moving SQL Data
             Across Applications


How do you export and import data into or out of a
 database?

What do we mean by .csv?




                                            #1
CS 105 Fall 2007   #2
About moving data. First, a few
        definitions…
  • The CSV (Comma delimited) file
    format
     – batting.csv
  • Text files (ASCII)
     – pitching.txt
  • HTML files
     – Batting.html


                CS 105 Fall 2007   #3
   Moving data into SQLyog from the Web

• Import data from author‘s website:
• http://www.forta.com/books/0672321289/
• Then use WinZip, and you have text scripts:




                        CS 105 Fall 2007        #4
First, run the ―create tables‖ scripts
    Just paste them into a query
 CREATE TABLE Customers
 (
    cust_id    CHAR(10)      NOT NULL,
    cust_name CHAR(50)       NOT NULL,
    cust_addressCHAR(50)     ,
    cust_city CHAR(50)       ,
    cust_state CHAR(5)       ,
    cust_zip   CHAR(10)      ,
    cust_country CHAR(50)    ,
    cust_contact CHAR(50)    ,
    cust_email CHAR(255)
 );



                            CS 105 Fall 2007   #5
         Then, select one table,
      and run its ―populate‖ script…
           paste it into a query
INSERT INTO Customers
(cust_id, cust_name, cust_address, cust_city,
   cust_state, cust_zip, cust_country, cust_contact,
   cust_email)
VALUES
('1000000001', 'Village Toys', '200 Maple Lane',
   'Detroit', 'MI', '44444', 'USA', 'John Smith',
   'sales@villagetoys.com');
‗etc.

                        CS 105 Fall 2007     #6
Transfer complete




             CS 105 Fall 2007   #7
  Moving data from SQLyog to Access

• Usually .csv files are the easiest way.

• Every piece of software has its own
  peculiarities—be flexible




                       CS 105 Fall 2007     #8
           Choose .csv Data




• This action saves the data in a file (csv
  means comma-separated-values)




                    CS 105 Fall 2007      #9
What does it look like now?
   • Each record is on its own line

   • Commas separate each field in each
     record




                   CS 105 Fall 2007   # 10
 Importing the data into Access
    (or any other database)
• Most databases allow you to import raw
  files as long as there is something to
  delineate the columns.
• With Access, create a new database but
  do not enter any data.




                   CS 105 Fall 2007   # 11
Choose type of data that you will import




                    CS 105 Fall 2007   # 12
Access automatically creates the columns




                   CS 105 Fall 2007   # 13
      You tell the database what
data types, constraints, names you want




                   CS 105 Fall 2007   # 14
 Now you
are all set:




               CS 105 Fall 2007   # 15
               To Summarize:

• How do you export and import data into or
  out of a database?

• What does .csv stand for?

• Your moment of Zen
link to importing demo film




                    CS 105 Fall 2007   # 16

				
DOCUMENT INFO
Categories:
Tags:
Stats:
views:1
posted:12/1/2011
language:English
pages:16