Announcement Announcement Module
No announcement yet.
Some way/tool to do this with database scripts backups Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Some way/tool to do this with database scripts backups

    Hello guys

    if i have for example
    a simple table call person

    with 'id' and 'name' how columns

    i can do a backup and get some file (A.sql)
    with all the inserts statements

    here, all fine

    how i can do this?

    for each insert statement generated in A.sql
    create a new B.sql, with update statements

    its possible do this?

    even worst, if a have a table with 20 columns
    i need the way to generate the same B.sql
    but with my desired columns to update

    thanks in advanced

  • #2
    What would you expect the update statements to look like? They would need to have a unique column value in each row to key off of...


    • #3
      hello pmularien

      let me explain me more

      think a table how this case

      cliente is customer/client in english

       Field             Type         Null     Key     Default     Extra    
       ----------------  -----------  -------  ------  ----------  -------- 
       idCliente         varchar(11)  NO       PRI                          
       razonCliente      varchar(80)  NO                                    
       direccionCliente  varchar(80)  NO                                    
       rucCliente        varchar(11)  NO                                    
       dniCliente        varchar(9)   NO                                    
       telefonoCliente   varchar(15)  NO                                    
       celularCliente    varchar(10)  NO                                    
       emailCliente      varchar(50)  NO                                    
       fechaNacimiento   date         NO                                    
       ciudad            varchar(20)  NO
      i would have 1 to N rows already inserted in the db,

      and i can do a simple backup with some script/administration tool for any database

      for instance A.sql
      which would has this content

      INSERT INTO `cliente` (`idCliente`,`razonCliente`,`direccionCliente`,`rucCliente`,`dniCliente`,`telefonoCliente`,`celularCliente`,`emailCliente`,`fechaNacimiento`,`ciudad`) VALUES 
       ('000273999','JOZEP E. VAN DEN OUWELAND','JIRON CONDE DE LEMOS # 226 - PUNO','','000273999','','','','2008-02-15','PUNO'),
       ('00454507','ALBERTO JESUS MARTIN LAZO FERNANDEZ','URB. SEŅORIAL H-4 CAYMA - AREQUIPA','','00454507','','','','2008-01-29','AREQUIPA'),
      the point is that table cliente has how you can see 10 columns for each insertion written by the backup

      the problem and my requirement is create a new sql file (called B.sql)

      with this content

      UPDATE cliente SET razonCliente='JOZEP E. VAN DEN OUWELAND', ciudad='PUNO' WHERE idCliente='000273999'
      UPDATE cliente SET razonCliente='ALBERTO JESUS MARTIN LAZO FERNANDEZ', ciudad='AREQUIPA' WHERE idCliente='00454507'
      so for each INSERT statement createad in A.sql i need generate a UPDATE statement in B.sql
      with the columns that i want to update, in this case
      razonCliente, ciudad

      why i need create a B.sql?,
      the reason is to have a batch with a lot UPDATE staments,
      so i can open the file and edit some row and a specific column that i need

      for instance
      UPDATE cliente SET razonCliente='JOZEP E. VAN DEN OUWELAND', ciudad='OTHER CITY' WHERE idCliente='000273999'
      UPDATE cliente SET razonCliente='I HAVE A NEW NAME', ciudad='AREQUIPA' WHERE idCliente='00454507'
      maybe i would need create a C.sql
      in this way
      UPDATE cliente SET ciudad='PUNO' WHERE idCliente='000273999'
      UPDATE cliente SET ciudad='AREQUIPA' WHERE idCliente='00454507'
      to only have the option to edit the column ciudad for some row

      i hope you see my point now

      thanks in advanced