Open rmorais01 opened 8 months ago
It's quite difficult it's require a db connection to derive SQL Select
statement INTO
a valid table definition and project the metadata with sp_help_text or get_ddl functions. the module doesn't include a database engine for derivation you are looking for.
@dmaresma I think idea was if create table
exists in same ddl script. In that case it is possible.
https://dev.mysql.com/doc/refman/8.0/en/create-table-like.html - we have support for 'LIKE' and 'CLONE' statements. I don't like idea to add SELECT - because it is part of DML, not DDL, but I will think about it, maybe add support only for this case
Is your feature request related to a problem? Please describe. A very useful addition to the simple-ddl-parser would be the ability to parse and process the SQL Create Table Using Another Table. Currently there is support only for the Create command, and hence this feature will extend the functionality of this DDL parser.
Describe the solution you'd like The solution must be able to parse the SQL CREATE command and create the table structure by referencing the table in the select statement which must exist in the same file. The new table gets the same column definitions.
Describe alternatives you've considered NA
Additional context Here are some examples for the Create Table Using Another Table command Syntax CREATE TABLE new_table_name AS SELECT column1, column2,... FROM existing_table_name WHERE ....;
Example CREATE TABLE Person ( person_id int, last_name varchar(255), first_name varchar(255), address varchar(255), city varchar(255) );
CREATE TABLE TestTable AS SELECT person_id, first_name, last_name FROM Person;