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.
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.
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.
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);
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:
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