Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot Create Table In phpPgAdmin [duplicate]

I'm using the PostgreSQL servers in phpPgAmin and all I want to do is create one table using SQL code. This is the code I'm using in its entirety.

CREATE TABLE BIDS (
 BIDID               NUMERIC(3) NOT NULL,
 CLIENTID            NUMERIC(3) NOT NULL,
 BIDDINGDATE         DATE,
 DESCRIPTION         TEXT,
 PRICE               NUMERIC(4,2),
 HOURLYRATE          BOOLEAN,
 APPROVED            BOOLEAN NOT NULL,
 COMMENTS            TEXT
 CONSTRAINT BIDS_PRIMARY_KEY PRIMARY KEY (BIDID));

This code should create the table, add some attributes and create a primary key. However, when I execute the SQL it throws this error.

enter image description here

I have no idea why that error occurs since there is no SELECT statement in my code. Is this a common occurrence with phpPgAdmin or PostgreSQL? If so, what should I do in order to create the table properly? Keep in mind that I need to do it using SQL code.

like image 496
Ben Avatar asked Nov 20 '14 09:11

Ben


People also ask

How do I duplicate a table in PostgreSQL?

To copy a table with partial data from an existing table, users can use the following statement: Syntax: CREATE TABLE new_table AS SELECT * FROM existing_table WHERE condition; The condition in the WHERE clause of the query defines which rows of the existing table will be copied to the new table.

How will you create a table from another table without data?

Question: How can I create a SQL table from another table without copying any values from the old table? Answer: To do this, the SQL CREATE TABLE syntax is: CREATE TABLE new_table AS (SELECT * FROM old_table WHERE 1=2);


1 Answers

The phpPgAdmin UI provides two links for running SQL - one in the main body of the page, and one in the menu bar at the top of the page.

The one in the main body of the page will throw the error you're seeing if you run a data definition statement like CREATE TABLE.

However, the one in the menu bar will run data definition queries with no problem.

In short:

enter image description here

like image 93
Sasi Avatar answered Sep 19 '22 23:09

Sasi