i want to create a simple table inside a database in postgresql.
From the Documentation i have CREATE TABLE will create a new, initially empty table in the current database. The table will be owned by the user issuing the command.
With this command
CREATE TABLE *table_name*;
I thought i get a new empty table.But psql throws ERROR: syntax error at or near ";"
. When i user an empty argument list like:
CREATE TABLE *table_name*();
psql tells me that the table was created through
postgres=# create table *table_name*();
CREATE TABLE
But \l shows is not showing the newly created table. And its also not possible to login with psql -d table_name -U user_name. Can anyone help?
You can have a table with no columns, and even with some rows in it:
CREATE TABLE nocolumn (dummy INTEGER NOT NULL PRIMARY KEY)
;
INSERT INTO nocolumn(dummy) VALUES (1);
ALTER TABLE nocolumn
DROP COLUMN dummy;
\d nocolumn
SELECT COUNT(*) FROM nocolumn;
Output:
CREATE TABLE
INSERT 0 1
ALTER TABLE
Table "tmp.nocolumn"
Column | Type | Modifiers
--------+------+-----------
count
-------
1
(1 row)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With