Search code examples
sqlpostgresqlsyntax-errorcreate-table

Pg admin 4 - error creating any new table


whenever I am trying to create a new table on PgAdmin 4 tool for postgresql I am getting an error

Query: CREATE TABLE geeks_table

ERROR: syntax error at end of input LINE 1: CREATE TABLE geeks_table ^ SQL state: 42601 Character: 25

enter image description here


Solution

  • As per the comments, you need to add the data definition language (DDL) to the create statement.

    The database needs to know what columns and data types are required, for example, the following DDL will create a 2 column table:

    CREATE TABLE geeks_table (
        code        INTEGER PRIMARY KEY,
        title       varchar(40) NOT NULL
    );
    

    If you're aiming for a table without columns, this is the syntax

    CREATE TABLE geeks_table ();