mysql

MySQL Insert of over 5 million rows - commit every x number of rows option

I dumped the data from a database using the MySQL Admin Migration toolkit. One of the tables has over 5 million rows. When I try to load the generated data file I get out of memory issues. Is there a way to force commit after X number of rows. The script generate by the migration toolkit is shown below. INSERT INTO mytable (`col1`, `co...

Should I use a big INT or regular INT in MySQL to store a timestamp?

Should I be using a big integer or a regular integer in MySQL to store a timerstamp in? I plan on storing it in an INT and not the built in timestamp or datetime so which INT type should I use? ...

MySQL Subgroup?

I'm still getting the hang of more advanced MySQL queries, so bear with me here... I have a table (1 table) with the following columns: name, source, destination, count I want to group my results by name, then subgroup them by the pairing between destination and source. So far all I have is this query: SELECT name, destination, sourc...

Storing arrays in MySQL?

On the Facebook FQL pages it shows the FQL table structure, here is a screenshot below to show some of it. You will notice that some items are an array, such as meeting_sex, meeting_for current_location. I am just curious, do you think they are storing this as an array in mysql or just returning it as one, from this data it really ma...

Python - automating MySQL index: passing parameter

Hi Everybody, I have a function with a new improved version of the code for automatic table indexing: def update_tableIndex(self,tableName): getIndexMySQLQuery = """SELECT numberID FROM %s;""" % (tableName,) updateIndexMySQLQuery = """UPDATE %s SET numberID=%s WHERE numberID=%s;""" % (tableName,) updateIndex=1 ...

Search over many different columns in different tables in Rails

I need to provide some kind of global search over most of the data that my application have. The data is distributed in different tables, like users, comments, etc. in MySQL. I do want to handle this in the application, not with something like Google Custom Search. My idea is to create table, which would have columns like source id and...

Timezone help in PHP/MySQL

I have been fighting the timezone battle for weeks now, everyone thinks they know the solution and then they get a million upvotes but the reality is I am totaly 100% stuck, no answer ever given for timezone support in PHP/MySQL has worked 100% for me, so I am asking the question again on here in as much detail as I possibly can with cod...

How do I insert into a mysql database using a loop for multuple rows?

I have data that will need to be added into a database. The data looks like this: Jim Jones 2009-01-01 Red Susan Hoo 2009-01-04 Red ... I am writing a procedure for this but don't know how to loop it so that it inserts all of the rows. Is there a tutorial or something that someone can show me to get me started? Thanks ...

What is wrong with mysql_num_rows()?

I have this code to get the user name that a friend has messaged to someone like user to from message. mysql_num_rows is not working and my user names come up as unknown. Does this have something to do with mysql_num_rows()? function getusername($userid) { $sql = "SELECT username FROM user WHERE `id` = '".$userid."' LIMIT 1"; ...

What software should I use for manually drawing schema diagrams?

Our application has a fairly large, sprawling DB design, with 175 tables. Most tables are used by one or two primary features, and I'd like to create several little "mini-schemas" to describe the structure of different parts of the system to new hires (without showing them the gigantic total schema which is, frankly, so big as to be use...

Does using a PHP class to run mysql queries like this bad?

I been looking at some database (MySQL) wrapper classes, A lot of them work like this, 1) Run the sql query 2) while fetching associative mysql array, they cyle through the results and add them to there own array 3) then you would run the class like this below and cycle through it's array <?php $database = new Database(); $result = $...

Should I store country names in mysql for each user?

Below is a PHP array I have, it has Countries list 1 to 228 with name and a number for that country. I used this on an old project where in the mysql DB I saved a user's country as a number and then I could use this array to avoid doing another mysql query on pages. Now I am doing a different site where performace is important. W...

Easy way to check if a page view is unique?

Hey guys, im building a small product catalog for a client. I am currently trying to figure out how to go about allowing the user to sort by "popularity". I figured the easiest/simplest way to do this would be by having a "views" field in each product record. Originally I didn't think this through (duh) and thought I would just add on...

INSERT IGNORE Inserting 0 rows

Hi Everyone: When I am attempting to run "INSERT IGNORE ..." in MYSQL to add only one variable to a table of several options, after the first insert, it refuses to work. It says "Inserted rows: 0" and doesn't insert my new value into the database. I believe this is because there is already an entry with a "nothing" value and MYSQL doe...

Binary data in MySQL

I need to store binary data, such as 1110000, in MySQL. When I select it, I need the return value to be the same 1110000 again. What data type should I use? Can I use bit? Or would varbinary be better? ...

Problems with utf8 encoding in database.yml discarding strings on insert

So I'm doing some screen scraping with this rails app I author, and when I go to insert some text from the page into the database ... rails refuses to do it (inserting empty strings into the db column instead). I looked more closely and realized that it was doing it if the string contains 'weird' characters. Weird character would be som...

Split records into two columns

I have a "student" table, having around 5,000 records, in my DB. I want to display those records in two divs. How do I do that without executing the query twice; only using a single query? ...

Advice on the most efficient way to plan-out a html/php & multi-user Ajax project.

I'm starting a experimental project and I was looking for advice to choose the best option I have. The project will be on the 100 - 1,000 user count. It collects its main data using javascript + json data from the user's flickr page and then uses that to display specific flickr photos. The variables that need to be stored include use...

Can I use stored procedures with ruby on rails ?

Can I use stored procedures with ruby on rails ? I am using mysql as database and ruby on rails. please provide me any of the example for this. ...

Mysql 5.1.42 alter table auto_increment = 0 doesn't work, truncate does

For my automated acceptance tests, I want inserts to start with id=1. I achieved this on one PC (XP 32bit, mysql 5.1.something) with (after deleting all rows from the table), "alter table tableName auto_increment = 0". I'm now setting up a new PC (Windows 7 64bit, mysql 5.1.42), and this command seems to have no effect. I can see in the...