py-polars/docs/source/reference/sql/table_operations.rst
.. list-table:: :header-rows: 1 :widths: 20 60
CREATE TABLE <create_table>DELETE FROM <delete_from_table>DROP TABLES <drop_tables>EXPLAIN <explain>SHOW TABLES <show_tables>UNNEST <unnest_table_func>TRUNCATE <truncate>.. _create_table:
Create a new table from a sequence of column definitions, a SQL query executed against an existing table, or create an empty table from the schema of an existing table.
Example:
.. code-block:: sql
CREATE TABLE tbl(colx VARCHAR, coly DATE, colz ARRAY<DOUBLE>)
.. code-block:: sql
CREATE TABLE new_table AS
SELECT * FROM existing_table WHERE value > 42
.. code-block:: sql
CREATE TABLE new_table LIKE existing_table
.. _delete_from_table:
Remove specific rows from a table using an (optional) constraint.
Omitting the constraint deletes all rows, equivalent to TRUNCATE.
Example:
.. code-block:: sql
DELETE FROM some_table WHERE value < 0
.. _drop_tables:
Deletes the specified table, unregistering it.
Example:
.. code-block:: sql
DROP TABLE old_table
.. _explain:
Returns the Polars execution plan for a given SQL query.
Example:
.. code-block:: sql
EXPLAIN SELECT * FROM some_table
.. _show_tables:
Returns a list of all tables registered in the given context.
Example:
.. code-block:: sql
SHOW TABLES
.. _unnest_table_func:
Unnest one or more arrays as columns in a new table object.
Example:
.. code-block:: sql
SELECT * FROM
UNNEST(
[1, 2, 3, 4],
['ww','xx','yy','zz'],
[23.0, 24.5, 28.0, 27.5]
) AS tbl (x,y,z)
.. _truncate:
Remove all data from a table without deleting the table itself.
Example:
.. code-block:: sql
TRUNCATE TABLE some_table