insert table within another table

Asked

Viewed 41 times

0

it is possible to insert one type of table inside another?
Example: I have the BOOK table and, inside it, I want to create a column of type AUTHOR (referring to the AUTHOR table itself).

  • 1

    It could not be a foreign key (ID_AUTOR) for example that references the primary key of the AUTHOR table?

  • Following the @Claytontosatti guideline, read https://www.devmedia.com.br/sql-learna-utilizar-a-chave-primaria-e-a-chave-estrangeira/37636

  • is that I’m riding the queries from the java code that I made. in my code, within the book class, has an attribute of the author type and wanted to do this pro sql too. I don’t know if my question is clear..

1 answer

1

It is possible yes! Here will give you a better sense, but already in advance:

INSERT INTO tabelaA SELECT * FROM tabelaB
  • but here’s the question: I’m still doing CREATE’s, can I do this when creating the table? Or it is better to create the table and then update by inserting this field?

  • 1

    Create and update :)

  • would look like this: ALTER TABLE BOOK ADD author ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.