|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
Copying records whithin table
Hello,
I need to copy all records whithin one table with change of primary key. table, for example looks like this: test.pkey test.name test.description I need do ( Code:
select * from test where pkey = 1 It means. copy all records with pkey=1 to the same table with another primary key. In fact I have more complex table and I don't want to change this code after change of structure 'test' table. (I don't want to list all fields from table) thank you Peter |
|
#2
|
||||
|
||||
|
Looks like you want and update ...
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
|
#3
|
|||
|
|||
|
Quote:
No, I don't want to change primary key value. I need copy all records with (let say) primary key = 1 to new records with primary key = 2. I need copy records, not move. so new records will contain the same values as old ones except primary key value. |
|
#4
|
|||
|
|||
|
Quote:
Try this: Code:
INSERT INTO test (pkey, name, description) SELECT 2, t2.name, t2.description FROM test t2 WHERE t2.pkey = 1 |
|
#5
|
|||
|
|||
|
Quote:
thank you, this is only way, how to do it? because after changing the structure it is necessary to change "copy" code also. is it possible to use '*' instead of listing all fields in some way? |
|
#6
|
|||
|
|||
|
Quote:
ops. of course. so primary key (in this case) is pkey+name |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Copying records whithin table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|