If you find duplicate entries when you run your code, or if the entries do not get inserted into the database, try changing the LINES TERMINATED BY clause to use \r\n instead. Note that you will have to add an IGNORE (highlighted above) at the beginning of your INTO TABLE clause, to tell SQL to ignore duplicate entries. ( `Lang_Name`) - and are just throwaway variables. Hence, when we import the file (using the SQL below), duplicate columns will be discarded. MODIFY COLUMN `Lang_Name` varchar(16) NOT NULL UNIQUE If the table has already been created, we can alter it. To ensure that the Language Name column does not duplicate itself, we can make the Lang_Name column for our table UNIQUE. However, because there are 4 rows in our data, importing the data directly will cause 4 rows to be imported into our Languages table. Users: When importing the users table, we will need to assign a Lang ID to it that represents the Language Name in the same column.įor the Languages table, we only need to import each Language Name once (for a total of 2 rows).Languages: This has to be created first, as the Users table has a foreign key that points to Lang Code.The tables can be represented with the following schemas: UsersĪrticle continues after the advertisement: Importing the data into 2 tablesīefore we begin, we will need to determine the order in which we will create the tables: Lang ID is introduced here to act as the surrogate primary key.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |