Page 1 of 1

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

Posted: Sun Dec 06, 2009 11:57 am
by arroya2
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

Re: Insertar un nuevo campo en una base de datos ya existent

Posted: Fri Mar 19, 2010 4:17 pm
by Czarny_Pijar
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.

Re: Insertar un nuevo campo en una base de datos ya existent

Posted: Fri Mar 19, 2010 7:07 pm
by mustafa
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

Re: Insertar un nuevo campo en una base de datos ya existent

Posted: Sat Mar 20, 2010 2:04 pm
by arroya2
Gracias a los dos, Czarny_Pijar y Mustafa.
Thank you both, and Mustafa Czarny_Pijar.

Muy agradecido
Much obliged
Rafael Pérez