Line starting string : Load Data Into Table « Backup Load « SQL / MySQL

Home
SQL / MySQL
1.Aggregate Functions
2.Backup Load
3.Command MySQL
4.Cursor
5.Data Type
6.Database
7.Date Time
8.Engine
9.Event
10.Flow Control
11.FullText Search
12.Function
13.Geometric
14.I18N
15.Insert Delete Update
16.Join
17.Key
18.Math
19.Procedure Function
20.Regular Expression
21.Select Clause
22.String
23.Table Index
24.Transaction
25.Trigger
26.User Permission
27.View
28.Where Clause
29.XML
SQL / MySQL » Backup Load » Load Data Into Table 
Line starting string
      
mysql>
mysql>
mysql>
mysql>
mysql> CREATE   TABLE TEAMS
    ->         (TEAMNO         INTEGER      NOT NULL,
    ->          EmployeeNO       INTEGER      NOT NULL,
    ->          DIVISION       CHAR(6)      NOT NULL,
    ->          PRIMARY KEY    (TEAMNO)             );
Query OK, rows affected (0.00 sec)

mysql>
mysql>
mysql> INSERT INTO TEAMS VALUES (1,  6'first');
Query OK, row affected (0.00 sec)

mysql> INSERT INTO TEAMS VALUES (227'second');
Query OK, row affected (0.00 sec)

mysql>
mysql>
mysql> LOAD DATA INFILE 'C:/TEAMS2.TXT'
    -> REPLACE
    -> INTO TABLE TEAMS
    -> FIELDS TERMINATED BY ','
    -> LINES TERMINATED BY '\r'
    ->       STARTING BY '/*/'
    -> ;

mysql> SELECT FROM TEAMS;
+--------+------------+----------+
| TEAMNO | EmployeeNO | DIVISION |
+--------+------------+----------+
|      |          | first    |
|      |         27 | second   |
+--------+------------+----------+
rows in set (0.00 sec)

mysql>
mysql> drop table teams;
Query OK, rows affected (0.00 sec)

mysql>

   
    
    
    
    
    
  
Related examples in the same category
1.Load data in txt file into database
2.load text data into table
3.Set division with
4.Importing CSV Files
5.Specifying the Datafile Format
6.To specify a file format explicitly, use a FIELDS clause to describe the characteristics of fields within a line
7.IGNORE is often useful with files generated by external sources.
8.Skipping Datafile Lines
9.Specifying the Location of Files on the Client Host
10.The syntax for a command to use a comma-separated text file, saved in a Windows format
11.IGNORE lines.
12.If you are using a Linux system, replace the '\r\n' in the LINES TERMINATED BY syntax command with just '\n'.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.