I'm attempting to make a table for the first time using postgres and the examples I'm seeing are kind of throwing me off. When it comes to creating a schema, I have a schema.sql file that contains my schema as follows:
CREATE TABLE IF NOT EXISTS orders
(
order_id INTEGER NOT NULL,
order_amount INTEGER NOT NULL
);
COMMENT ON COLUMN orders.order_id IS 'The order ID';
COMMENT ON COLUMN orders.order_amount IS 'The order amount';
Now I'd upload that schema by doing the following:
psql -d mydb -f /usr/share/schema.sql
Now when it comes time to create the table I'm suppose to do something like this:
create table schema.orders(
order_id INT NOT NULL,
order_amount INT NOT NULL
);
The uploading of the schema.sql
file is what confuses me. What is all the information inside the file used for. I thought by uploading the schema i'm providing the model to create the table, but running create table schema.orders
seems to be doing just that.