I am trying to write a script that will copy all the data in table a to table b if table a exists. Table b is the exact same structure as table a would be if it exists, though it may not. I am able to copy using the following statement: INSERT INTO 'B' SELECT * FROM 'A', but I don’t know where to use IF EXISTS, or if I even can to determine if I an perform the insertion. I am trying to do this in SQL only as it will be run through as a .sql script from the command line.
I am trying to write a script that will copy all the data in
Share
MySQL only:
Expand to you’re liking comparing the column definition in INFORMATION_SCHEMA.COLUMNS for A & B if you need finer control.