1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] How to create table like another table with additional columns in MYSQL

Discussão em 'Outras Linguagens' iniciado por Stack, Setembro 28, 2024 às 18:12.

  1. Stack

    Stack Membro Participativo

    I have 'Name, Age, Gender' columns in a 'test' table.

    I now, want to create another table 'test1' which will have these columns : 'Name, Age, Gender, Occupation'.

    How do I do it without creating and then altering? Is there any way to do it in a single line?

    I tried adding one column, but I was able to add it at the start only, like: CREATE TABLE test1 (Occupation VARCHAR(50)) LIKE test;

    This would result in 'Occupation, Name, Age, Gender'.

    I tried CREATE TABLE test1 LIKE test (Occupation VARCHAR(50)) which gave me an error.

    How to add columns at last while creation?

    Continue reading...

Compartilhe esta Página