Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Dump (quick) A Table Into Another One


On MySQL, I've got a table I use as 'wild card'. I mean, I store
data into it and, at the end, I dump all the date into 'production'
table.

Until now, I perform it following these steps:
1) I empty 'production' table
2) I make a SELECT of every rows of the 'wild card' table and an
INSERT into 'production' table.
3) I empty 'wild card' table.

But I've got problem: during SELECT+INSERT time, 'production' table
is not full and there's a data lack.

I'm looking for a faster way. Does anybody know it? Thank you very
much.

PS: I was told about 'mysqldump', but I do not know if it's faster
than mine.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Dump (quick) A Table Into Another One.
On MySQL, I've got a table I use as 'wild card'. I mean, I store
data into it and, at the end, I dump all the date into 'production'
table.

Until now, I perform it following these steps:
1) I empty 'production' table
2) I make a SELECT of every rows of the 'wild card' table and an
INSERT into 'production' table.
3) I empty 'wild card' table.

But I've got problem: during SELECT+INSERT time, 'production' table
is not full and there's a data lack.

How To Dump (quick) A Table Into Another One.
On MySQL, I've got a table I use as 'wild card'. I mean, I store
data into it and, at the end, I dump all the date into 'production'
table.

Until now, I perform it following these steps:
1) I empty 'production' table
2) I make a SELECT of every rows of the 'wild card' table and an
INSERT into 'production' table.
3) I empty 'wild card' table.

But I've got problem: during SELECT+INSERT time, 'production' table
is not full and there's a data lack.

Dump Table Definitions Only
I was wondering if anyone had an idea how I can dump a db's table definitions only so I can import into another machine. I dont want any of the old data though.... I have 0 mysql experience...

Mysql Dump Table Order
How does mysql order the tables in the file that it creates? Is is it by the order the tables were created, by alphabetic order? can I specify an order by giving the table names in the command line?

Japanese Text Dump To Table
I'm trying to upload the content of a TXT file in Japanese (JSHIFT) into a table with the command LOAD DATA INFILE, but everytime I've tried, I receive a warning that the text is being cropped and then it doesn't display properly on my webpage (although it's encoding is properly set with :

<meta content="text/html; charset=Shift_JIS" http-equiv="content-type"/>).

I'm tired of trying, so I decided to ask in case anyone has experience with text in other encoding formats.

Dump Table Scheme And Data...
Is there a way, without PHPMyAdmin, or the command prompt, (Meaning I have to use a self created php file) to download a MySQL database, keeping the table settings, and the data within them. Or am I pretty much stuck with trying to figure this out from reading over the PhpMyAdmin source codes and figuring it out that way?

My reasons are this:

I am switching online hosts to a new server, since my current host is using frame advertising, which messes up PHP codes a lot with it comes to submitting data. Now, I try to access phpMyAdmin, but my access is denied(along with many members)for some reason, and the only way to get access would be to deactivate my SQL privledges, and reactivate them. (Which kills all the data completely, removing the point of gaining access.) We(as in me and other members) have complained, and the server so far has turned a deaf ear to us for several months now. (Connecting to SQL on PHP pages made by the user is still working though)

So, is there any easy way to download a database onto my computer without PhpMyAdmin ....

Mysqldump Does Not Dump Single Table Contents
I just started learning to use mysqldump, which I found very useful in dumping database contents in xml format. However I was unable to dump contents of a single table. I tried following command:

mysqldump <database_name>.<table_name> --password --force --xml

Intrestingly, I am able to dump contents of the entire database via this command:

mysqldump <database_name> --password --force --xml

Quick Join
I have two tables Matches (m_id, m_winner_id, m_loser_id) and Users (u_id, u_name). m_winner and m_loser_id are foreign keys.

Now I want the querry result to look like this: Match ID | Winner Name | Loser Name.

I did a join query:
Select matchs.id, users.name From matchs, users Where matchs.winner_id = users.id

How do I get the loser name?

Quick Fix 4 MySQL Pro
I will have a few instances like this and since I'm new to MySQL, perhaps a good example will help down the road. All I want to do is display a list of the first and last name of the names in my DB so they appear like so:

John Smith
Suzie Johnson
Etc...

first and last are two separate fields in the DB so I just need to join them together. The code I have now gives me this error:
PHP Notice: Undefined index: first in e:etc...

<?php
// Request the names in db
$result = mysql_query("SELECT artist.first, artist.last FROM artist");
if (!$result) {
echo("No artists posted at this time");
exit();

code...

Quick Join
I have a quick SQL question:
I have two tables Matches (m_id, m_winner_id, m_loser_id) and Users (u_id, u_name). m_winner and m_loser_id are foreign keys. Now I want the querry result to look like this: Match ID | Winner Name | Loser Name.

I did a join query:
Select matchs.id, users.name From matchs, users Where matchs.winner_id = users.id
How do I get the loser name?

Quick PhpMyAdmin
I believe I got phpMyAdmin setup to work right, I used HTTP authentication, and I get a log in screen when I goto the url. How do I set up an account for that?

GRANT ALL PRIVILEGES ON acct1_db.* TO 'Brian'@localhost IDENTIFIED BY 'password';

Is that right? I wish to host websites off this computer and have multiple users. Do I need to log in to the controluser account to do it? Or am I way off?

Quick Query
this one shoud be easy, but I just can't think of the best way (other than writing a php script to do it). I have a CMS and need to change one word in the description field for 64 rows. For example, where we now have 64 entries with "Bilbo" in the middle of the data, we need to change it to say "Frodo" instead. (Actually, I need to replace a misspelled javascript toLowerCase() call...darned non-programmers! They used toLowercase() - note the lower case C)

Quick Queries
Is it possible to use a regular expression or similar in a mySQL query, to make 'fuzzy' comparisons, or is LIKE the best we can hope for?

QUICK AND EASY ONE
im fairly new to php/mysql so please bear with me
I am trying to upload a txt.file created from an excel spreadsheet using the following query:

LOAD DATA INFILE 'path/file.txt' INTO TABLE my_table;

im getting a syntax error!
what could be wrong? are there any other attributes i should be adding to this query? i also tried uploading a csv version of the same file and get the same error.

Quick COUNT()
The MySQL documentation says:

COUNT(DISTINCT expr,[expr...])

Returns a count of the number of different non-NULL values.
How do i get it to INCLUDE null values? I am using COUNT with the DISTINCT bit as well, and i want the NULL rows to count as one as well.

Quick Tip: Switching Field On/off
Ever wanted to change a database field (typically TINYINT(1)) from 1 to 0 or from 0 to 1 depending on the current value?

No need for two queries. I just thought of this 'clever' way to take care of it. Never saw that done this way before, and should have thought earlier about this.

UPDATE articles
SET published = ABS(published - 1)
WHERE id = x

Quick Ones To Speed Up Access
------=_NextPart_000_0032_01C35FC2.62884DE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am querying from a table containing more than 40,000 records. Earlier =
when the records were 10,000 it was taking 9 sec and now after 1 year =
and 40,000 records its taking 30 sec. Code is the same.=20

I am pretty sure that it has something to do with database only. No body =
can think of spending 30 secs for retrieving values from tables unless =
it's very huge in the sense of millions of records. =20

I don know whether I have to modify my database or do some sort of =
restructuring or reindexing so as to make it fast enough.

Is there some methods or optmization which can be applied to this =
database which hasn't been touched since design to enhance the spped.=20

If there are some quick ones but valued alottttttt please let me know.

Quick Date Subtraction Question
When I do the following, I get the number of days in difference between two dates however for the dates that have expired, I get the number of days back negated, ie -3 for example?

What I actually want is that if there has been an expiration, I want the result for a given row to be 0. Anyone got an idea how to?

// timestamp is datetime creation of record
// expires is date in future, ie 7, 14, 21 or 28 days in that increments
mysql> select day( expired ) - day( now() ) as days from polls;
Here is an example of the data returned,

+------+
| days |
+------+
| 7 |
| 7 |
| -3 |
| 7 |
| 7 |
| 21 |
| 7 |
| 7 |
| 14 |
| 21 |
| 7 |
| 21 |
| 7 |
| -3 |
| 21 |
| -3 |
| 7 |
| 7 |
| 7 |
| 14 |
| -3 |
+------+

Quick And Easy Update Query? Or Not Possible?
I need to do a global change to a column in my database. I know this is poor planning on my part, but I recently made a change to all of my image extensions for speed purposes.

I have a column called thumbnail_path, and every value ends with .GIF. I would like to change them to all end in .JPG. How can I do this? Is this even possible to do in one update query? or will I need to select, parse w/ php and then update?




Quick Question - Id Mediumint(8) - Does The (8) Matter?
just a quick question really..

Just setting up 1 of my tables and just wondering if it matters if i set my id to mediumint(8) but i only ever get to 6, will this effect anything in anyway?

Same goes for - address varchar(50) and say that no address ever reachs 50?


Quick & Easy MySQL Sync?
Does anyone know of any quick and easy way to sync a local development mysql server to a remote server and back. I'd like to be able to optionally sync either direction?

Quick Mysql Auto_increment Question
i noticed that after adding some test data into my table the autoincrement is working fine. but after i delete them, even though the table is empty again the new data i put in will have primary key thats in auto_increment as if the old data was there.

for example i added in 2 rows. now i have an id 1 and id 2. i delete them and the table has no rows. but now i add another two rows after wards and they get assigned id 3 and id 4. is there anyway for me to make the counting start over??? thanks for any replies or thoughts on this.

Quick Question About Reseting Demo Database?
I would like to set up a cron job to reset my demo database on a regular basis. Is there a way to export an sql file via phpmyadmin, and run it as a whole via the PHP mysql commands? The only way I can see to do it, I have to split up the exported sql from phpmyadmin into individual queries. I'd like to just process the entire .sql file at once, as it would make maintenence much easier.

Multiple WHERE X='$x' In A Query. (Quick Answer Needed)
My query works when I only use one WHERE instance, but not with both, and i know I have data that matches both criteria. Is this the proper way to pull results that match 2 criteria?

$query = "SELECT * FROM Cartridges WHERE TYPE='$TYPE_Query' & PRINTER='$PRINTER_Query' ORDER BY ID ASC";

Dump Db
I'd like to set a cron job to do a db dump on a scheduled basis (for back-up purposes). I know how to work with cron, but am unsure of the commands to use to effect the dump.


Importing Dump Using SSH
I have made a dump of a site using phpMyAdmin, and stored the dump as /httpdocs/myDump.sql.gz. I am trying to restore it using SSH with the following command:
mysql -u myUserName -p myPassWord -h myHost myDatabase < /httpdocs/myDump.sql.gz
and get the prompt:
-bash: /httpdocs/myDump.sql.gz: No such file or directory
when it clearly does exist. The main problem is that the host cannot allow you to create a new database via phpMyAdmin, so i have to import the dump using SSH. This means that the database i am trying to create ("myDatabase") doesn't yet exist - am i right in assuming the restore will create it (it contains the commands to do so)? Otherwise, what is going wrong?



Dump And Load
Tried to do move from version 4 to version 5.
I use "source" under mysql prompt.
so far, I have two questions
1. in one of the sql file, there is a field with name "1" and I just couldn't load it.
2. in another sql file, one of the table has many fields, I couldn't load that in the version 5 either until I removed ten fields (not acceptable).

where are those settings?

Dump Files
I have a dump file and I want to import into my database.
I try to do this command in mysql consol(mysql.exe)
source C:/file.dump;
but d'ont work
How can I do to work ???

Data Dump
I can take data into a database from an sql file with:

mysql -u USER -p DBNAME < dump.sql

But how do I send data out of an sql table, to an sql-type text file? Don't
I simple change the redirection symbol from "less than," to "greater to," as
follows:

mysql -u USER -p DBNAME dump.sql

Whenever I do this, however, it just hangs (even on tiny databases, so I
must have something syntactically wrong here).

Mysql Dump
I'm using MYSQL dump to back-up my database. What if i don't want the data inside the tables? How can i have it back up the tables but not the data?

currently i'm using:
mysqldump -h localhost -u tony -p test > test.sql

Mysql Dump
I have a database on my local machine, so i am connecting to localhost.

I am trying to execute a simple command through the MySQL console: mysqldump --opt quicken > quickenback.sql.

Can't seem to get it to work. Have tried in quotes, etc.

Any ideas?

BTW, I am running a delphi application which is connected to MySQL databases on both Windows (localhost) and Linux machines as I write this, so it is not a connection problem.

Is There A Trans Log To Dump?
I am creating some scripts to do some maintenance on a MySql database. Is there such a thing as a transaction log that should be dumped/cleared periodically? And how?

Mysql Dump
I want to load specific columns into a new table.

current_table:
recno, name, phone, active

new_table:
recno, address, active

I want to load:
select recno, active from current_table where active=1

into the new table.

do i use mysql dump? how do I put the query into the mysql dmp?

MySQL Dump
is there a way of making a mysql dump that would work in a php form sort of thing ?

i have a mysql database, and a few tables and in a specific table records of 'clients' and i wanted a script that would search for a 'client' with ID eg '4' and export all the 'client's with the ID of 4 and then show the data of which the file would contain.

Mysql Dump
Im trying to get mysqldump to create a text file that looks good in excel

atm Im using (anything inside ' 'is just a filled in field)

mysqldump --tab=C:data --opt 'database' -u 'login' -p --lines-terminated-by=''

The problem is that I want my rows to all be one line. And if the user pressed enter while inputting data into a text field the text file is giving it a new line inside the .sql file. ex. it looks like this

--
--
--

when I want the output to be like this ------

is it possible to somehow remove the newlines in a field before it does the dump so that it's all in the same line.

(or if not I'd love to be pointed to any kind of good tutorial on how to get a good text or csv output of a database so that I can import it into excel)

Perl Dump
Does somebody have a perl script to dump some or all databases on a local server (win32) ?I've done with msdos bat, but not so easy and flexible.

Dump A Database
What is the command to dump a database through MySQL Command line Client.

Restory A Dump
i'm having troubles trying to restore a mysql dump file with MySql Administrator.
It's the dump of a genetic db downloadable from the db website but the file size is 6 gb and my system stops without any error message during the restore and doesnt go on.
Is it cause the file is too big and MySql cannot handle it.

Mysql Dump
My client wants to frequently be able to dump his mysql db for use in excel (csv file is fine as well). I don't want him fiddling around with phpmyadmin and messing things up. Is there a script or some shortcut which would allow him to just dump to excel with a "click of a button"

Import Sql Dump
I can't recover my database from a SQL Dump built by phpMyAdmin because of the following problem:

The dumb has sql commands for creating the tables, but has the command "UPDATE" rather than the "INSERT" data command. Since the DB is empty, I can't import the data because the update command does not work without having the respective database entries, as specified by "WHERE" (part of the UPDATE command). For example:

UPDATE `results` SET `rid` = 19844, `sid` = 28, `qid` = 251, `avid` = 3629, `entered` = 1101883926, `sequence` = 1556 WHERE `rid` = '19844';


How can I get around manually inserting the data required by the WHERE command before importing the sql dumb?

Mysqldump Never Dump
I am trying to dump an existing database data to a new database. I did the mysqldump:

mysqldump -u root -p db2 < db1_backup.sql

I did that, and when I go to mysql prompt to show tables, then select * from table1, I got no result. I am clueless what I did wrong.

Sql Dump Import
I'm writing a forum script. so i need an install script. so, it would be easy if i had an sql dump and let the installation import it. it connects to the db ok. I got this off a friend but does not work


$fromfile = @file("pb.sql");

if(!$fromfile){
$main = "We could not read the SQL data from pb.sql";
} else {

$queries = split("; ", implode("", $fromfile));
foreach($queries as $query){
if(!mysql_query($query)){
echo mysql_error();

MYSQL DUMP
Im trying to export my table in csv formatt? I cant seem to get it to work im getting this error:
mysqldump: unknown option -s

i dont have a -s in my script heres my script:

mysqldump -u root -fields -terminated-by=,-tab= c: emp -tables ehpadmin direct_referral > new.txt

Dump To SQLite
I am trying to dump the data to import in SQLite.
I used --compatible=ansi option.
What is the correct syntax / options to be used with mysqldump for this purpose?

Sql Dump File
278 meg dump and I cant figure out how to get it in to its new home on another server, errors out before any data is transfered. Locks up for 15 minutes and then errors out. How can I split this file and upload at the required size for mysql

Dump Database
I'm only interested in having a manually generated backup in the form of an SQL file containing a series of "DROP TABLE...CREATE TABLE...INSERT" statements, which I can reload if necessary. I can do this from within phpMyAdmin, but I'd really like to know how to do this myself from within my Apache/PHP-based website code on my home PC so that I can create the text file at the push of a button. I'm writing some PHP code to manage some date via a web interface. I can't seem to find in the docs exactly how to do this except from the server command line using mysqldump.

MySQL Dump
I have done some research into a mysql dump, but cant really figure out the syntax. If I have a table names dis, and with user name of root and password of password, what sort of string would I need?

Dump Settings
A primary server is running mysql 4.1. The backup is running 4.0. I have a schedules dumb from primary to secondary occuring nightly. I just realized that the import to the secondary DB is generating errors due to:
ENGINE=MyISAM AUTO_INCREMENT=40 DEFAULT CHARSET=latin1

Is there any setting in the primary db dump to dump the file for version 4.0? Or any other thoughts? We have anumber of things going on and have decided not to upgrade the backup mysql version just yet.

Shell And Sql Dump
Does anyone know where I can find information on how to setup my shell in
unix/linux to allow me to restore a database from an sql dump...
I have a database on 83200.mysql.com (example) that I have a file mysql.sql
(also just an example).
The file was produced using an sqldump command from a web interface...
How can I configure a connection if I am not on 83200.mysql.com so that I
can import the data into a database with a name of database_wordpress


Copyright © 2005-08 www.BigResource.com, All rights reserved