Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CREATE TABLE ... LIKE ... syntax #1187

Open
ClayenKitten opened this issue Oct 19, 2024 · 0 comments
Open

Add CREATE TABLE ... LIKE ... syntax #1187

ClayenKitten opened this issue Oct 19, 2024 · 0 comments

Comments

@ClayenKitten
Copy link

CREATE TABLE newTableName LIKE templateTableName allows creating the table with the same structure as an already existing one, and is especially useful when creating temporary tables.

It is supported by PostgreSQL and MySQL.

I suggest the following syntax:

await db.createTable("newTable")
    .like("oldTable")
    .including("INDEXES"); // Only for PostgreSQL.
    .including("COMMENTS") // User may specify multiple including statements, maybe we should use accept array as parameter instead?
    .excluding("DEFAULTS") // Excluding is the default, but can be useful with `.including("ALL")`.
    // ...

I may look into implementing that, if that feature would be accepted into the project. Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant