160 likes | 254 Views
Moving SQL Data Across Applications. How do you export and import data into or out of a database? What do we mean by .csv?. About moving data. First, a few definitions…. The CSV (Comma delimited) file format batting.csv Text files (ASCII) pitching.txt HTML files Batting.html.
E N D
Moving SQL Data Across Applications How do you export and import data into or out of a database? What do we mean by .csv? CS 105 Spring 2010
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 Spring 2010
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 Spring 2010
First, run the “create tables” scriptsJust 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 Spring 2010
Then, select one table,and run its “populate” script…paste it into a query INSERT INTOCustomers (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 Spring 2010
Transfer complete CS 105 Spring 2010
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 Spring 2010
Choose .csv Data • This action saves the data in a file (csv means comma-separated-values) CS 105 Spring 2010
What does it look like now? • Each record is on its own line • Commas separate each field in each record CS 105 Spring 2010
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 Spring 2010
Choose type of data that you will import CS 105 Spring 2010
Access automatically creates the columns CS 105 Spring 2010
You tell the database whatdata types, constraints, names you want CS 105 Spring 2010
Now you are all set: CS 105 Spring 2010
To Summarize: • How do you export and import data into or out of a database? • What does .csv stand for? link to importing demo film CS 105 Spring 2010