Welcome Guest, Not a member yet? Register   Sign In
Insert 1 milion record
#1

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
Reply
#2

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
Reply
#3

(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)
Reply
#4

(This post was last modified: 09-29-2017, 02:20 PM by ciadvantage.)

(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.
Reply
#5

(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
Reply
#6

My pleasure!
Reply
#7

(09-30-2017, 02:20 PM)ciadvantage Wrote: My pleasure!

My Love!
Reply
#8

(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?
Reply
#9

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

Obtain access.
Reply
#10

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB