If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Clone dynamic table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-11-09, 05:04
sandyssn sandyssn is offline
Registered User
 
Join Date: Feb 2009
Posts: 7
Lightbulb Clone dynamic table

hi guys ,

Good to be a part of you all! Let me get straight to work
Is there a way to clone dynamic table? I mean to say that I do 'show create table' and 'create table alias-name' and then 'insert option' but they result only in giving me data currently present in the table. My requirement is a table which keeps on adding values in the cloned table as and when I add data to the original table .. Now as a good database programmer you are supposed to use data in a cloned table for all your operations going back to the basics right !

Well I'm not very much familiar with replication concepts and all I know about it is replication is used for long-distance and different servers! Can it be implemented here pertaining to this context in the same server which more or less performs like a dynamic cloned table is what I name it?
Reply With Quote
  #2 (permalink)  
Old 02-11-09, 05:19
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by sandyssn
Now as a good database programmer you are supposed to use data in a cloned table for all your operations going back to the basics right !
no, that's not right

can you please explain with more detail why you need a clone table?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-11-09, 05:37
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Are you talking about an audit / history table?
__________________
George
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 02-12-09, 01:03
sandyssn sandyssn is offline
Registered User
 
Join Date: Feb 2009
Posts: 7
Re: Clone dynamic table

Well I would explain it evidently!

First I create a table called friends with so-and-so parameters ..

create table friends(name varchar(25) not null, degree varchar(10) not null, initials varchar(5) not null, marks decimal(4,1) not null, datentime datetime not null primary key);

and then I insert data as follows ..

insert into friends values('femil','bsc','a',59,'2008-12-09 20:20:57');
insert into friends values('arun','bsc','k',64,'2008-12-09 20:21:57');
insert into friends values('edwin','bsc','c',72,'2008-12-09 20:22:57');
insert into friends values('aravind','bsc','a',58,'2008-12-09 20:23:57');

Now I have a set of records in my table. Now I clone the table by

show create table friends \G;
*************************** 1. row ***************************
Table: friends
Create Table: CREATE TABLE `friends` (
`name` varchar(25) NOT NULL,
`degree` varchar(10) NOT NULL,
`initials` varchar(5) NOT NULL,
`marks` decimal(4,1) NOT NULL,
`datentime` datetime NOT NULL,
`filename` varchar(20) DEFAULT NULL,
PRIMARY KEY (`datentime`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)


and create an alias-table

CREATE TABLE `friends2` (
`name` varchar(25) NOT NULL,
`degree` varchar(10) NOT NULL,
`initials` varchar(5) NOT NULL,
`marks` decimal(4,1) NOT NULL,
`datentime` datetime NOT NULL,
`filename` varchar(20) DEFAULT NULL,
PRIMARY KEY (`datentime`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1

Now I insert my 'friends' table by

insert into friends values('sandeep','bsc','s',75,'2008-12-09 20:24:57');

Well, here comes my question now ..

This insertion is obviously not reflected in 'friends2'. What should I do so that this insertion is also reflected or added in the cloned table here 'friends2' not only once but als o infinite number of times i insert or update or delete rows from the original table 'friends'

Note: Please dont tell me to insert it at the beginning itself. This is just a prototype and I'm doing a real-time concept whatever I told you! Any ideas friends?
Reply With Quote
  #5 (permalink)  
Old 02-12-09, 04:45
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
you could write a trigger

but my question was... why do you need a cloned table in the first place?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 02-12-09, 05:35
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Perhaps he's thinking of replication?

Still can't think of why he'd want to do anything other than read from the original table though. Perhaps he needs to revisit those basics he mentioned?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On