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




Copy/move Whole Table


I'm doing a conversion on a customer database and I'd like to take this chance to a lil learning

I have v4_customer:
v4_id | login | points

and v5_customer:
v5_id | login

I want to move it to customer_conversion:
v5_id | login | points

Is there a way to do a table wide join (or equivelant) on the field login and move all of the info to customer_conersion? The table is about 15,000 records. It will only be run once or twice on a development machine, but I figure if there's a better way to do it, why not learn. Is there a better way than to loop through each row?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Mysql Move Table Content To Another Table
How do I move the contents from one table to another table in the same
database. ie the contents of "cart table" to "orders table" thus removing the
contents of the "cart table" and placing it in the "orders table".
I have looked everywhere for a simple method other than the long winded Select, Insert and the Deleting.

Move Rows From One Table To Another?
Is there a direct way to move a row from one table to another?

Or do I need to go while through the original table, insert a new row in my new table, then remove it from the old table?

How Could I Move A Table From One Database To Another?
I have a *damaged* MyISAM stock_take_mst.frm in /var/lib/mysql/abc.
And I would like to move it to /var/lib/mysql/test and experiment with it.

Is there a MySQL command to detach and attach a table?

Delete From One Table But Move The Info To Another
Is there a way to say in MySQL, please,

DELETE * FROM ThisTable INSERT into ThatTable;

Move Records From 1 Table To Another And Including 1 Field
I've created a table called `temp` and I want to move all the rows in `temp` to `songs` based on:

`temp`.`title` -> `songs`.`title`
`temp`.`artist` -> `songs`.`artist`
`temp`.`catalog` -> `songs`.`catalog`
NOTHING -> `songs`.`userid`

There is no field in the temp table that has this value, i will need to insert it along with each record. How would I go about doing that, without looping through 1 query and inserting each as I go?

Write/Move/Save Pdf To MySQL Table?
Is upload the only way to pass a file to a table?

I have a contract.pdf which is generated via php (FPDF) and saved in a temporary file. I need that file then moved /written to the appropriate customer table in our database (MySQL ) so that the temporary file may then be overwritten by the next Customer/Order.

While I am able to upload the file via <input type="file" name="uploadpdf> and related uploader.php, asking our web-users to “browse” for the file does not suit our needs, and of course adding a default value

<input type="file" name="uploadpdf" value="http://localhost/crm/modules/Orders/contract.pdf"> doesn’t work either.

As the file is always the same (modules/Orders/contract.pdf) how may I manage that move automatically, (say with a ‘Confirm Order’ button) to the database?

Move Table Row To Top Or Bottom Of SQL Table
Is there a way, using a standard SQL database query, to send a single row of a table to either the top or the bottom of that table.....

How To Copy Row(s) Into Same Table
Is there some easy way to copy row(s) from/to same Table?

MySQL HELP says (in 13.1.4.1 INSERT ... SELECT Syntax): "Currently, you cannot insert into a table and select from the same table in a subquery."

Copy Table
I have a table which I have added a column to, I want to copy the value of the first column to the last column for all rows. Is there an SQL query to do this or should I use perl DBI?

Copy Field To Another Table
I have 2 tables and would like to populate field2 in table 2 with the user field from table1. All i can find is examples of UPDATE for moving data within the same table. How do I UPDATE field2 with data from Table 1?

How To Copy Records In One Table?
does anybody know how to copy a record within one
table? I am looking for some simple method similair to
INSERT INTO orders SELECT * FROM orders WHERE
Order_ID=256; Actually, this method does not work and
I can not believe that MySQL does not offer some
simple method how to do it. Keep in mind that I have a
60-field table. So, naming all fields is a pretty
tedius task.

Copy DATETIME From One Table To Another
I'm trying to copy a DATETIME field from one table to another using an INSERT statement like this:

INSERT INTO table2 (value1, date1)
SELECT (value1, date1)
FROM table2;

MySQL gives me this error:

Error 1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' date1) FROM table2'

Date1 is a DATETIME field in both tables. I'm not trying to insert the current date or a timestamp. Date1 needs to move unchanged.

Copy Table To A New Database
really need ur help guys on how to form a php code to transfer data from 1 table to another table which is the summary of the original table. For example, i have a table, named mobal and the structures of the table are as below:

mysql> desc mobal;
+--------------+---------------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+---------------------------+------+-----+---------------------+-------+
| RecordID | int(10) unsigned | | | 0 | |
| DateInsert | datetime | | | 0000-00-00 00:00:00 | |
| DateSend | datetime | | MUL | 0000-00-00 00:00:00 | |
| MobileNumber | varchar(11) | | | | |
| MONumber | varchar(20) | | | | |
| Message | varchar(225) | | | | |
| Status | enum('Success','Failure') | YES | | NULL | |
+--------------+---------------------------+------+-----+---------------------+-------+

in this mobal table, there are millions of data and i want it to be summarized in the new table by transfering only the amount of data on any particular date. The structure of new summarized table is:

mysql> desc mobalsum;
+-------------+----------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------+------+-----+---------------------+-------+
| NewDateSend | date | | | 0000-00-00 | |
| TotalSum | int(10) | | | 0 | |
+-------------+----------+------+-----+---------------------+-------+

and then, my application will be using this new summarized table which is mobalsum for querying purpose.the reason of im doing this is because, im just thinking this way in order to speed up the query as an alternative since the use of index still cause my application very much slow when retrieving millions of data.

Copy Table To Another Database
I have two tables and I'd like to copy some contents of table 1 to a specific field table 2. Their (the tables) purposes are the same, but the structure is different. There are some fields present only in table 1 and others only in table 2.

Is this possible?

How To Copy Records In One Table?
does anybody know how to copy a record within one
table? I am looking for some simple method similair to
INSERT INTO orders SELECT * FROM orders WHERE
Order_ID=256; Actually, this method does not work and
I can not believe that MySQL does not offer some
simple method how to do it. Keep in mind that I have a
60-field table. So, naming all fields is a pretty
tedius task.

Copy Table Data
How can i copy all data from tmclktrx table into my_tmclktrx table.

SELECT EMP_NO, `DATE`, SCHE_CODE, SCHE_TYPE, TREAT_AS, IN1, OUT1, IN2, OUT2, IN3,
OUT3, HR_MIN
FROM `tmclktrx`
INSERT INTO emp_no, `date`, sche_code, SCHE_TYPE, TREAT_AS, IN1, OUT1, IN2,
OUT2, IN3, OUT3, WORK_HOUR
FROM my_tmclktrx

can anyone help me repair the code.

Copy Table From One Database To Another
i have two databases in mysql server, How i can copy one table from one database to the other one?

Copy Large Table?
I want to copy just part of a very large table from one database to another database. The table contains several million of rows.

So far the only thing I can think of is using MySql dump. However, that will give me all the rows in that table, right? But I just want to grab 1000 rows to do testing.

Copy Data From One Table To Another
I want to retrieve all records from one table and insert them into another table. Can this be done in one statement?

Copy Record From One Table To Another?
I've successfully installed and created a database for my company's web portal, which contains a Staff Directory. The thing is, I need a second data base with for the former staff. Is there a way to write a SQL statement that will delete the record from the current employee table, and add it to the former employee table?

Copy And Rename Table
I have a table that I'm using as the 'default' table to be used in a game creation

When a new game is created, I'd like to be able to copy the table and rename it, something like game_map_29. The 29 will be the variable generated for the next game. The new game_map table will than be modified as the game progresses.

Can someone maybe give an example on copying and renaming table?

SQL-Statement To Copy A Table Into A New One
i want to copy many records from one table into a new one. I found only the statement to export to an file and reimport them, but i don't like this version.

Example:

select * from abc where Status = "C" into outfile "abc-c";
truncate table abc-c;
load data infile "abc-c" into abc-c;

Copy Table With Autoincrement
I have tried a lot to copy a table with php, but I can't:

I tried first:
CREATE TABLE copy SELECT * FROM table

but it doesn't copy autoincrement or primary key. Deleting the autoincrement column, and then assigning it, does however makes an auto_increment column, but the values doesn't correspond with the original, because some posts where deleted there, and then the auto_increment values are higher.

Then I tried to assign those two values later, by first truncating.
CREATE TABLE copy SELECT * FROM table";
$sql2="TRUNCATE TABLE copy";
$sql3="INSERT INTO copy SELECT * FROM table";
$sql4="ALTER TABLE copy ADD PRIMARY KEY (id)";
$sql5="ALTER TABLE copy CHANGE `id` `id` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT";
$sql6="ALTER TABLE copy AUTO_INCREMENT=$maxid

but that doesn't work either. Isn't there a simple way to copy a table including the primary key and the autoincrement with php?

Copy Of An Existing Table
MySQL: How I make a copy of an existing table in phpMyAdmin or SQL ?

without copy data
with copy and data

Copy Column From One Table To Another
I have managed to get:

update table_A , table_B set table_B.col_1 = table_A.col_1 where table_B.col_# = table_A.col_#

to work on PHPMyAdmin 2.6.1-pl3 with MYSQL 4.0.16


but it will not work on PHPMyAdmin 2.6.0-pl3 with MYSQL 3.23.58;

Copy A Really Huge Table
I have a really huge table that I need to copy however using the Export function in MySqlAdmin does not work because it "times out". All I really need to do is generate an SQL script that will, drop the table if it exists, create the table and its structure, and then insert the data line by line.

Usually when you perform a command in MySqlAdmin through Internet Explorer the MySQL command line is displayed with the results. However, this does not happen when you export.

Anyone know how to do this from the MySQL command line?

In a nutshell: I need to backup a table to an SQL script file.

Searching A Copy Of A Table
Code:

CREATE TABLE `submitted_answers` (
`id` int(11) unsigned NOT NULL auto_increment,
`survey_id` int(11) unsigned NOT NULL default '0',
`question_id` int(11) unsigned NOT NULL default '0',
`answer_id` int(11) unsigned NOT NULL default '0',
`other_value` text,
`user_id` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) TYPE=MyISAM


One of the questions in a survey asked about the users age. I have now been asked to pull the other answers out by how the users answered the age question. I've tried a few different ways of searching a copy of the table but the numbers being returned aren't what I'm expecting. I'm not sure what I'm doing wrong. Here's my latest try that's giving me a number that's much too large.
Code:

SELECT count( tbl1.id ) AS count, answers.answer_text
FROM `submitted_answers` AS tbl1, `submitted_answers` AS tbl2, answers
WHERE tbl2.question_id =2
AND tbl2.answer_id =7
AND tbl2.user_id = tbl1.user_id
AND tbl1.answer_id =1
AND tbl1.question_id =1
AND tbl1.answer_id = answers.id
GROUP BY answers.id

The ids I have listed for tbl2 are selecting (or at least I think they are) how the user answered the question about age. The example shown (tbl2.question_id = 2 AND tbl2.answer_id = 7) would be the users that said they were 50+. I'm then (once again, I think I am) relating the 2 table copies by user_id to match up the rows and getting how the users in tbl2 answered the question in tbl2. As I said, this query is giving me much bigger numbers than could be true and I'm not sure why.

Copy Row Data In Same Table
I am trying to make a script that will copy data from around seven tables to another row in the table. This works fine for the first table using the insert

INSERT INTO customers (list, of, fields) SELECT list, of, fields FROM customers where customer_id = customer_number

but in the rest of the fields I dont see how it can work customer_id is the key and I want to make sure they all have the same key. Do I have to do a select first to get all the data where the id = cusomer_number then an insert a new record into the table with the new customer_id generated from the first insert?

Copy Line Of A Table
Is it possible to copy 1 or more lines out of a table into another table?
I am trying to create a kind of a mini backup sys. Every time a user erases/changes a table, I would like to document this change in another table. What I had in mind was simply to copy the line that was changed into another table and keep it for a certain period of time.

Copy Automatically A Table
How it is possible to always copy automatically a table for another different database that the first table will be brought up to date?

Copy Table Structure
can you show me how to copy a structure of table into another table

Copy Records From One Table To Another Table
What is the sql query in mysql which copies all records from one table to another table within a database...? and query that copies records from one table to another that belongs to a different database...

Copy Rows From One Table To Another Table
One is the "main" machine and all the others will synch data up with it it once in a while. Is there a command to insert rows into one table on a different machine using the table on the current machine? Like....

Main Table 1 on main machine e.x. 192.168.1.1
name|email|listdate
------------------------
tom|a@b.com|1-1-2005
dick|c@d.com|1-1-2005
harry|e@f.com|1-1-2005
etc.



Temp Table 1 on field machine e.x. 192.168.1.2
name|email|listdate
-----------------------
larry|g@j.com|6-1-2005
mike|h@k.com|3-1-2005
fred|i@l.com|5-1-2005


i know you can do something like the following if they are both located on the same machine but i don't know how to structure the command for different machines:

insert into real_table (col1, col2) select x, y from temp_table;


Copy The Result Of A Query Into Another Table.
I am trying to make a select with a sum in it and group by account and copy the results in another table.

As the site has the 4.0.25 MySQL version i guess i cant make subconsults. I thought of storying the results in vectors, but up to now it didnt work ...

Copy Changed Records Into Same Table
Is there any way to select several records from one Table, and copy them back to same Table but with changed values of one field (for instance: values of Foreign key field)?
((records with original values needs to remain in Table))

I Need To Copy A Table To Another In The Same Database But With Filters?
I need to copy a table to another in the same database but with filters?

SELECT * FROM table1
WHERE table1.field1 LIKE '%.gif%'
Insert into table1.field2;

Update table1.field2
Select * from table1.field1
WHERE `table1.field1` LIKE '%.gif%';

Insert into table1.field2
SELECT * FROM table1.field1
WHERE table1.field1 LIKE '%.gif%';

I hope that makes sense, any ideas?

Mysqldump Over Netowrk: Copy Table Instead Of Entire Network
mysqldump over network is working just fine like the following.

mysqldump -ukzu -p jokes | mysql -h 192.168.1.190 -ukzu -p jokes

I was wondering how I would copy a table in "jokes" instead of the whole db. Say if my table name was named "people" in the jokes table.

What To Do To Copy[triple] A Table['land' To 'villas' To 'apts'] In Phpmyadmin
what to do to copy[triple] a table['land' to 'villas' to 'apts'] in phpmyadmin, not the contains ?

CREATE TABLE `land` (
`photourl` VARCHAR( 40 ) NULL ,
`id` VARCHAR( 5 ) NOT NULL ,
`name` VARCHAR( 40 ) NOT NULL ,
`priceeuro` DECIMAL( 9, 2 ) NULL ,
`pricecyp` DECIMAL( 9, 2 ) NULL ,
`beds` VARCHAR( 1 ) NULL ,
`description` VARCHAR( 500 ) NULL ,
`location` VARCHAR( 20 ) NULL ,
`area` VARCHAR( 20 ) NULL ,
`detailsurl` VARCHAR( 40 ) NULL
) ENGINE = MYISAM COMMENT = 'Land for sale in Pafos';

How To Copy A Table Into Another Table?
I have two tables test1 and test2

what query do I run if I want to add table 'test2' entries into 'test1' entries?

insert into test1 select * from test2 works however the problem I have is if test2 and test1 have the same primary key id it won't work.

example test2 table
id name
1 nothing

test1 table
1 something

They both have the same primary key "id" so it doesn't work.

I tried:

insert ignore into test1 select * from test2 but it doesn't copy anything....im stumped.

Move MySQL Table To Another MySQL Table
Hi Hope you can help little stuck with this trying to move a table to another table and then delete after.
This is the code:
php

mysql_select_db("databasename"); (this works its the next bit)

$result = mysql_query("INSERT INTO $poarchive SELECT * FROM $poform" )
or die($errCon . mysql_error());

echo "Database has been moved to the archive and has been Deleted!";

mysql_close($con);

Error message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELCT * FROM poform' at line 1

Move Table From A Database To Another Table In A Database
I am currently developing a project as I am only a web designer.

I need to move a table from a database to another table in a database.

I am using SQL Server 2005 Express. How is this done?

I have been stuck for months trying to figure this out!

I have even bought SQL Server Express 2005 for Dummies and cannot figure this out!

I need someone to hold my hand and walk me through this literally! Or give me syntax code to do this.

Move DB From One To Another
how do i go about moving a database between two computers that are networked together.

Move A Row
Been looking for a while with no luck. e.g. I have 10 rows in the table. I would like to move row 6 below row 3. Is that poss? Not sure how i would go about setting it up.

Can't Move Data From 1 DB To Another
I have two servers that are running linux with a MySql DB running on each.  The old server is running MySql 4.0.20 and the new one is running MySql 4.1.12.  What I am trying to do is move all the data from the old to the new.  So here is what I have done so far.  I used phpmyadmin to dump the data and structure and used it to rebuild the new db.  Most all things went alright except for some float fields.  Some data that should be 18.75 is 9.99.  I have tried to use SQLyog enterprise (trial edition) and got the same results.  I look at the structure of the table and in both the DBs it is the same, it is the data that is messed up.  Is this a difference in the two MySql versions, and if so how can I fix this?

How To Move MySQL 4.1.14 From C: To E: ?
While the first time install my Windows Server 2003, I just only partition one partition to save all thing ...

But now, After thinking of if I in the future need format the Windows 2003 since the total server out of service or virus attacks etc... all of my web site and database will all gone ...

So, now I want to reinstall and repartition the partition the test server before it release to public, How to backup the full database by using MySQL Administrator Tool 1.2.2?

I just want to know how to move the DB from C: to E:, do I need reinstall the MySQL 4.1.14?? Or any other easy way?? On the moving cycle, do I need stop the MySQL service??

My folder now in C: is like this

C:InnDB Database File
C:Program FilesMySQL <--- (under this folder, have data and other mysql's binary file etc)

And I am a newbie, afraid using the command, But a bit knowledge to using the MySQL Administrator Tool 1.2.2

Move Database
I originally installed MySQL 5.0 on my C drive to learn and figure out how to integrate. Now I want to go live and move it to our agency's share drive.

I moved all the folders over, but when I add or drop databases they get added to or dropped from my C drive, not my share drive. What am I missing?

How To Move Tables
how to move tables from one database to another on the same computer?

Move A Database To Another Pc
I have used Access2MySQL to change an access database to mysql but now I need to share that with other developers in my class. We are using mysql and java for a project for school. We need to share the database but none of us have really used mysql before (teacher to).

We did a prototype in access and are now making the program in java using mysql. the problem is how to share the database either over the internet or just make copies for each of us to use. We all have mysql loaded on our personal machines.

What would be the best way to share the database? we are using sun jse 8 for the IDE. I have made conncections to my database in java and ran a simple test program. I have used msSql but not mysql.

50 MB MySQL CB - How To Move?
I've been trying to get a 50 MB SQL DB moved from one server to another.


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