Insertar un nuevo campo en una base de datos ya existente.

HMG en Español

Moderator: Rathinagiri

Post Reply
arroya2
Posts: 160
Joined: Thu Aug 06, 2009 7:16 am

Insertar un nuevo campo en una base de datos ya existente.

Post by arroya2 » Sun Dec 06, 2009 11:57 am

En Español.
Hola a todos.
Necesito modificar una base de datos que existe en diez diferentes carpetas, y necesito añadir nuevos campos a su estructura. Mi pregunta es si existe una función que lo haga.

Saludos.
Rafael Pérez

In English.
Hello everyone.
I need to modify a database that exists in ten different folders, and I need to add new fields to its structure. My question is whether there is a function to do so.

Greetings.
Rafael Perez

User avatar
Czarny_Pijar
Posts: 172
Joined: Thu Mar 18, 2010 11:31 pm
Location: 19.2341 E 50.2267 N

Post by Czarny_Pijar » Fri Mar 19, 2010 4:17 pm

In English: Better late than never
In Polish: Lepiej późno niż wcale.

It's depends how much the bases you have to elaborate.

1,2 or 3: the program named 'HMG Data Base Assistant' aka DBA is probably the shortest way.

If much more, or you want to do this programically, take this snippet into account:
*-----------------------snippet begin

*--- snapshot of the structure of the base
use my_base new
copy stru exte to basestru
close databases

*---restructure
use basestru new
append blank
repl Field_name with 'NEW_FIELD' ,;
Field_type with 'N' ,;
Field_len with 13 ,;
Field_dec with 2
close databases

*---creating the new base
create my_new_b from basestru
close databases

*--- copying records
use my_new_b new
append from my_base
close databases

*--- cleaning
erase basestru.dbf
erase my_base.dbf
rename my_new_b.dbf to my_base.dbf

*-----------------------snippet end

The snippet was intended to be selfexplanatory, I hope this helps.
Important: delete and re-create all indexes relevat to your modified base.
Last edited by Czarny_Pijar on Sat Mar 20, 2010 11:05 am, edited 1 time in total.

User avatar
mustafa
Posts: 586
Joined: Fri Mar 20, 2009 11:38 am
Location: Alicante - Spain
Been thanked: 44 times
Birthday

Post by mustafa » Fri Mar 19, 2010 7:07 pm

Hello arroya2 (Raphael)
If you can not serve an application that I created to build
my databases, should go into "View Database" Put the name
Dbf File and then "View Structure" has two buttons, one
"New Record", here's the New Field Name, if Numeric,
Date, etc. Locigo. Modified once you go to the menu and put "New Sin Index"
and go to "View Browse" and see the base changes with the new field.
Logically all information in the database will lose and I advise
that before doing anything, make a copy of the DBF file, I can not guarantee
function as you expect.

*----------------------------------------*
Hola arroya2 (Rafael)
No se si te puede servir una aplicación que tengo creada para creame
mis bases de datos, tendrias que entrar en "Ver Base" Poner el nombre
del Fichero Dbf y luego "Ver Estructura" tienes Dos Botones , uno de ellos
"Nuevo Registro", aqui le indicas en Nombre del Nuevo Campo si es Numerico,
Fecha , Locigo etc. una vez Modificado vas al Menu y pones "Nuevo Sin Index"
y te vas a "Ver Browse" y veras la Base Cambiada con el Nuevo Campo.
Logicamente toda la información de la Base de datos se Perderá y te aconsejo
que antes de hacer nada, hagas una copia del Fichero DBF, no te garantizo
que funcione como tu esperas.

Saludos
Mustafa
Attachments
dBu_ML.zip
(880.01 KiB) Downloaded 161 times

arroya2
Posts: 160
Joined: Thu Aug 06, 2009 7:16 am

Post by arroya2 » Sat Mar 20, 2010 2:04 pm

Gracias a los dos, Czarny_Pijar y Mustafa.
Thank you both, and Mustafa Czarny_Pijar.

Muy agradecido
Much obliged
Rafael Pérez

Post Reply