archiving table records to another table by trigger(move daialy table records to weekly table, evry day)


Rafael V. Souza
HOME ยป Databases

I have written this trigger in mysql 5:


create trigger changeToWeeklly after insert on tbl_daily for each row
begin
insert into tbl_weeklly SELECT * FROM vehicleslocation v
where v.recivedate < curdate();
delete FROM tbl_daily where recivedate < curdate();
end;


i want to archive records by date, move yesterday inserted record from dailly to weekly table and last weekly table to mounthly table and deletes this records from previous table
this trigger has following error when insert in daily tabled occurred :
"Can't update table 'tbl_daily' in stored func


Related to : archiving table records to another table by trigger(move daialy table records to weekly table, evry day)
archiving table records to another table by trigger(move daialy table records to weekly table, evry day)
Databases

I have written this trigger in mysql 5:


create trigger changeToWeeklly after insert on tbl_daily for each row
begin
insert into tbl_weeklly SELECT * FROM vehicleslocation v
where v.recivedate < curdate();
delete FROM tbl_daily where recivedate < curdate();
end;


i want to archive records by date, move yesterday inserted record from dailly to weekly table and last weekly table to mounthly table and deletes this records from previous table
this trigger has following error when insert in daily tabled occurred :
"Can't update table 'tbl_daily' in stored func

Move million records from MEMORY table to MYISAM table
Databases

I am looking for a fast way to move records from a MEMORY table to MYISAM table. MEMORY table has around 0.5 million records. Both tables have exactly the same structure (same number of columns, data types etc.). But the MYISAM table is indexed (B-TREE) on a few columns. There are around 25 columns most of which are unsigned integers.


I have already tried using "INSERT INTO SELECT * FROM " query. But is there any faster way to do this?


Appreciate your help.


Prashant


How do I copy data from each record of one table into multiple records of another table related to the first table?
16/12/2014 4:20 pm Databases

I'm working in SQL server 2012. I need to migrate data from one table to another, but I need to duplicate the data as well. Here is the setup:

Table A has a 1 to many relationship to Table B. Some of the data in each record in Table A needs to be moved to multiple records of Table B related to the Table A record. Each record in Table A needs to copy its data into multiple records of table B for any records in Table B that link to a given Table A record. I need a way to do this with a single SQL UPDATE if at all possible, and I need to understand how the SQL works. I've not been able to find a way to do this through Google or searching SO.

Table A:
ID : int
Name : varchar2
Age : int
Type_ID : int
Rating : int

Table B:
ID : int
Table_A_ID : int
Name : varchar2
Age : int
Subject_ID : int
Note : varchar2

So in this example Age and Name need to be copied from Table A to all records of Table B that share Table_A_ID with Table A's ID field. Once the migration is successful I will remove Name and Age from Table A.


Combine multiple records in a table into one field in another table based on fields in a third table
Databases

I have three tables:


Table 1:
pid, name, address
1 Dale BLANK
Table 2:
pid, moid
1 12
Table 3:
moid, address
12 123 Main
12 12 South
12 99 North

For output I need:


Table 1:
pid, name, address
1 Dawn 123 Mian,12 South,99 North

How can i combine multiple addresses in table 3 into one address field in table 1 linking the two tables with information in table 2?




HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .