CREATE TABLE IMSIPSFL ( ROW_ID SERIAL, SIPS_SONG_CODE int4 NOT NULL, SIPS_IPLINK_ID int4 NOT NULL, SIPS_SEQUENCE_NO int4 NOT NULL, SIPS_IP_TYPE bpchar(1) NOT NULL, SIPS_IP_CODE int4 NOT NULL, SIPS_TERR_CODE bpchar(4) NOT NULL, SIPS_ORIG_TERRITORY bpchar(1) NOT NULL, SIPS_CHAIN_ID int4 NOT NULL, SIPS_PARENT_IPLINK_ID int4 NOT NULL, SIPS_CAPACITY_CODE bpchar(4) NOT NULL, SIPS_CONTROLLED bpchar(1) NOT NULL, SIPS_CONTRIBUTION NUMERIC(6,2) NOT NULL, SIPS_MECH_OWNED NUMERIC(6,2) NOT NULL, SIPS_PERF_OWNED NUMERIC(6,2) NOT NULL, SIPS_SYNC_OWNED NUMERIC(6,2) NOT NULL, SIPS_OTHER_OWNED NUMERIC(6,2) NOT NULL, SIPS_MECH_COLLECT NUMERIC(6,2) NOT NULL, SIPS_PERF_COLLECT NUMERIC(6,2) NOT NULL, SIPS_SYNC_COLLECT NUMERIC(6,2) NOT NULL, SIPS_OTHER_COLLECT NUMERIC(6,2) NOT NULL, SIPS_IPSHARE_CODE bpchar(4) DEFAULT ' ' NOT NULL, SIPS_COMPOSER_CONTRIB NUMERIC(6,2) DEFAULT 0 NOT NULL, SIPS_AUTHOR_CONTRIB NUMERIC(6,2) DEFAULT 0 NOT NULL, SIPS_EMP_FOR_HIRE bpchar(1) DEFAULT ' ' NOT NULL, SIPS_AUTHOR_PUB_ALLOC NUMERIC(6,2) DEFAULT 0 NOT NULL, SIPS_COMPOSER_PUB_ALLOC NUMERIC(6,2) DEFAULT 0 NOT NULL, SIPS_PUBLISHER_ALLOCATION NUMERIC(6,2) DEFAULT 0 NOT NULL, SIPS_IGNORE_CONTROLLED bpchar(1) DEFAULT ' ' NOT NULL, SIPS_EXCLUDE_FROM_REG bpchar(1) DEFAULT ' ' NOT NULL, CONSTRAINT Q_MPUBFILE_IMSIPSFL_SONGCODE_00001 PRIMARY KEY (ROW_ID) ); -- public.imsipafl definition -- Drop table -- DROP TABLE public.imsipafl; CREATE TABLE imsipafl ( ROW_ID SERIAL, SIPA_SONG_CODE int4 NOT NULL, SIPA_IPLINK_ID int4 NOT NULL, sipa_assignor_link_id int4 NOT NULL, Agreement_no int4 NOT NULL, CONSTRAINT q_mpubfile_imsipafl_songcode_00001 PRIMARY KEY (SIPA_SONG_CODE,SIPA_IPLINK_ID,sipa_assignor_link_id, Agreement_no), CONSTRAINT q_mpubfile_imsipafl_songcode_00002 FOREIGN KEY (ROW_ID) REFERENCES IMSIPSFL(ROW_ID) --CONSTRAINT q_mpubfile_imsipafl_agreement_no_00003 FOREIGN KEY (Agreement_no) REFERENCES IMAGRDFL(Agreement_no) ); -- public.msngfl definition -- Drop table -- DROP TABLE public.msngfl; CREATE TABLE msngfl ( ROW_ID SERIAL, SNGA_SONG_CODE int4 NOT NULL DEFAULT 0, SNGA_IPLINK_ID int4 NOT NULL, snga_song_title bpchar(50) NOT NULL DEFAULT ' '::bpchar, snga_song_type bpchar(1) NOT NULL DEFAULT ' '::bpchar, snga_original_song int4 NOT NULL DEFAULT 0, snga_date_created date NOT NULL, snga_owning_sys_terr bpchar(2) NOT NULL DEFAULT ' '::bpchar, snga_date_orig_publ date NOT NULL, snga_date_local_pub date NOT NULL, snga_first_recording_date date NOT NULL, snga_lead_sheet bpchar(8) NOT NULL DEFAULT ' '::bpchar, snga_composers bpchar(80) NOT NULL DEFAULT ' '::bpchar, snga_group_1 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_group_2 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_group_3 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_group_4 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_group_5 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_group_6 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_num_sub_codes int4 NOT NULL DEFAULT 0, snga_num_akas int4 NOT NULL DEFAULT 0, snga_num_samples int4 NOT NULL DEFAULT 0, snga_territory_contd bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_1 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_perc_1 numeric(7, 3) NOT NULL DEFAULT 0, snga_catalog_2 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_perc_2 numeric(7, 3) NOT NULL DEFAULT 0, snga_catalog_3 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_perc_3 numeric(7, 3) NOT NULL DEFAULT 0, snga_catalog_4 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_perc_4 numeric(7, 3) NOT NULL DEFAULT 0, snga_catalog_5 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_perc_5 numeric(7, 3) NOT NULL DEFAULT 0, snga_catalog_6 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_perc_6 numeric(7, 3) NOT NULL DEFAULT 0, snga_catalog_7 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_perc_7 numeric(7, 3) NOT NULL DEFAULT 0, snga_catalog_8 bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_perc_8 numeric(7, 3) NOT NULL DEFAULT 0, snga_date_added date NOT NULL, snga_added_by bpchar(10) NOT NULL DEFAULT ' '::bpchar, snga_time_added time NOT NULL, snga_date_amended date NOT NULL, snga_amended_by bpchar(10) NOT NULL DEFAULT ' '::bpchar, snga_time_amended time NOT NULL, snga_song_time numeric(5, 2) NOT NULL DEFAULT 0, snga_pub_domain_date date NOT NULL, snga_reversion_date date NOT NULL, snga_principal_artist bpchar(35) NOT NULL DEFAULT ' '::bpchar, snga_delete_ind bpchar(1) NOT NULL DEFAULT ' '::bpchar, snga_contract_ref bpchar(7) NOT NULL DEFAULT ' '::bpchar, snga_lyric_sheet_rcvd bpchar(1) NOT NULL DEFAULT ' '::bpchar, snga_trad_pd bpchar(1) NOT NULL DEFAULT ' '::bpchar, snga_sngl_album_title bpchar(35) NOT NULL DEFAULT ' '::bpchar, snga_label_code bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_catalog_no bpchar(15) NOT NULL DEFAULT ' '::bpchar, snga_country_code bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_language_code bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_department_code bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_work_4_hire_ind bpchar(1) NOT NULL DEFAULT ' '::bpchar, snga_demo_no bpchar(12) NOT NULL DEFAULT ' '::bpchar, snga_serious_music_ind bpchar(1) NOT NULL DEFAULT ' '::bpchar, snga_song_status bpchar(4) NOT NULL DEFAULT ' '::bpchar, snga_top_earners_ind bpchar(1) NOT NULL DEFAULT ' '::bpchar, snga_iswc_code bpchar(11) NOT NULL DEFAULT ' '::bpchar, snga_ship_status bpchar(1) NOT NULL DEFAULT ' '::bpchar, snga_alpha_title bpchar(50) NOT NULL DEFAULT ' '::bpchar, CONSTRAINT q_mpubfile_msngfl_songcode_00002 FOREIGN KEY (ROW_ID) REFERENCES IMSIPSFL(ROW_ID) );
Write, Run & Share PostgreSQL queries online using OneCompiler's PostgreSQL online editor and compiler for free. It's one of the robust, feature-rich online editor and compiler for PostgreSQL. Getting started with the OneCompiler's PostgreSQL editor is really simple and pretty fast. The editor shows sample boilerplate code when you choose database as 'PostgreSQL' and start writing queries to learn and test online without worrying about tedious process of installation.
PostgreSQL is a open source relational database system and is also knows as Postgres.
CREATE command is used to create a table, schema or an index.
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
....);
ALTER command is used to add, modify or delete columns or constraints from the database table.
ALTER TABLE Table_name ADD column_name datatype;
TRUNCATE command is used to delete the data present in the table but this will not delete the table.
TRUNCATE table table_name;
DROP command is used to delete the table along with its data.
DROP TABLE table_name;
RENAME command is used to rename the table name.
ALTER TABLE table_name1 RENAME to new_table_name1;
INSERT Statement is used to insert new records into the database table.
INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);
Select statement is used to select data from database tables.
SELECT column1, column2, ...
FROM table_name;
UPDATE statement is used to modify the existing values of records present in the database table.
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
DELETE statement is used to delete the existing records present in the database table.
DELETE FROM table_name where condition;