CodeIgniter Forums

Full Version: Insert 1 milion record
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have many record that my operator have to insert it to database
Also i have to check this record's ID for existing it in database
What is best way to add them in database and check existing ID in database
Example:
Name ID
Omid 1
Tohid 2
Saed 3
Abbas 4

Suppose referenced records is 1 million
I want to know how add records in database and check which id is duplicate
Well if ID is primary key then it should be auto-incremented as you set it, so it is taken care off already. Your example is like
ID isnt. I would have it as primary key then problem is solved
(09-29-2017, 01:25 PM)ciadvantage Wrote: [ -> ]Well if ID is primary key then it should be auto-incremented as you set it, so it is taken care off already.  Your example is like
ID isnt.  I would have it as primary key then problem is solved

Ok for insert ID,my problem solved.
Now how do i insert many record?(about 1 million)
(09-29-2017, 01:31 PM)omid_student Wrote: [ -> ]
(09-29-2017, 01:25 PM)ciadvantage Wrote: [ -> ]Well if ID is primary key then it should be auto-incremented as you set it, so it is taken care off already.  Your example is like
ID isnt.  I would have it as primary key then problem is solved

Ok for insert ID,my problem solved.
Now how do i insert many record?(about 1 million)

you can do from code level but it is not recommended.  I found it is easier just use this

https://dev.mysql.com/doc/refman/5.7/en/load-data.html

ie. using command from mysql > LOAD DATA INFILE 'users.txt' INTO TABLE yourdb.users;

/* Assume you have db name as yourdb and table users, your users.txt should be comma seperated */

Try a simple test file with few names to see how it goes then you can go from there.
(09-29-2017, 02:17 PM)ciadvantage Wrote: [ -> ]
(09-29-2017, 01:31 PM)omid_student Wrote: [ -> ]
(09-29-2017, 01:25 PM)ciadvantage Wrote: [ -> ]Well if ID is primary key then it should be auto-incremented as you set it, so it is taken care off already.  Your example is like
ID isnt.  I would have it as primary key then problem is solved

Ok for insert ID,my problem solved.
Now how do i insert many record?(about 1 million)

you can do from code level but it is not recommended.  I found it is easier just use this

https://dev.mysql.com/doc/refman/5.7/en/load-data.html

ie. using command from mysql > LOAD DATA INFILE 'users.txt' INTO TABLE yourdb.users;

/* Assume you have db name as yourdb and table users, your users.txt should be comma seperated */

Try a simple test file with few names to see how it goes then you can go from there.

It is good solution THanks
My pleasure!
(09-30-2017, 02:20 PM)ciadvantage Wrote: [ -> ]My pleasure!

My Love!
(09-29-2017, 02:17 PM)ciadvantage Wrote: [ -> ]
(09-29-2017, 01:31 PM)omid_student Wrote: [ -> ]
(09-29-2017, 01:25 PM)ciadvantage Wrote: [ -> ]Well if ID is primary key then it should be auto-incremented as you set it, so it is taken care off already.  Your example is like
ID isnt.  I would have it as primary key then problem is solved

Ok for insert ID,my problem solved.
Now how do i insert many record?(about 1 million)

you can do from code level but it is not recommended.  I found it is easier just use this

https://dev.mysql.com/doc/refman/5.7/en/load-data.html

ie. using command from mysql > LOAD DATA INFILE 'users.txt' INTO TABLE yourdb.users;

/* Assume you have db name as yourdb and table users, your users.txt should be comma seperated */

Try a simple test file with few names to see how it goes then you can go from there.

Hey i cannot access to command line mysql
How do it?
(11-07-2017, 08:42 AM)omid_student Wrote: [ -> ]Hey i cannot access to command line mysql
How do it?

Obtain access.
(11-07-2017, 08:54 AM)Narf Wrote: [ -> ]
(11-07-2017, 08:42 AM)omid_student Wrote: [ -> ]Hey i cannot access to command line mysql
How do it?

Obtain access.

Yes Yes
Pages: 1 2