plsql - Why will my PL/SQL Coding not work, when trying to create 5 tables and insert 5 samples into each table? -
create table phone_customer( customer_id int not null, first_name varchar2(20) not null, last_name varchar2(20) not null, e_mail varchar2(20) not null, address varchar2(20) not null, first_name varchar (20) not null, city varchar (20) not null, state char (2) not null, age int not null, zip int not null, phone varchar(30) constraint phone_customer_pk primary key (customer_id) ); create table phone_order( order_id int not null, customer_id int not null, item_id int not null, shipping_method_id int not null, shipping_status_id int not null, quantity int not null, shipping_date date, total_due decimal(18,2) credit_card_number char(16) credit_card_expiration varchar2(5) constraint phone_order_pk primary key (order_id), constraint fk_customer_id foreign key(customer_id) references customer(customer_id), constraint fk_item_id foreign key(item_id) references item(item_id), constraint fk_shipping_method_id foreign key(shipping_method_id) references shipping method(shipping_method_id), constraint fk_shipping_status_id foreign key(shiping_status_id) references shipping status(shipping_status_id) ); create table phone_item( item_id int not null, brand varchar2 (20) not null, model varchar2 (20) not null, e_mail varchar2 (20) not null, operating_system varchar2 (20) not null, price decimal(18,2), screen_size decimal(4,2), camera_resolution varchar2(10), network varchar2(4), ram int not null, storage int not null, talk_time int not null, color varchar2(16), constraint phone_item_pk primary_key(item_id) ); create table phone_shipping_method( shipping_method_id int not null, name varchar2(20) not null, price decimal(18,2) not null, constraint phone_shipping_method_pk primary_key(shipping_method_id) ); create table phone_shipping_status( shipping_status_id int not null, name varchar2(20) not null, reset_shipping_date date not null, constraint phone_shipping_status_pk primary_key(shipping_method_id) ); insert phone_shipping_status(shipping_status_id,name, reset_shipping_date)values(5029508, 'james',to_date( '010988', 'mmddyy')) phone_shipping_status(shipping_status_id,name, reset_shipping_date) values(450767, 'james walker',to_date( '050978', 'mmddyy')) phone_shipping_status(shipping_status_id,name, reset_shipping_date) values(3, 'jim curack',to_date( '070989', 'mmddyy')) phone_shipping_status(shipping_status_id,name, reset_shipping_date) values(8, 'jaime heimberger',to_date( '070989', 'mmddyy')) phone_shipping_status(shipping_status_id,name, reset_shipping_date) values(9, 'dwayne johnson',to_date( '100999', 'mmddyy')) select * dual; insert phone_shipping_method(shipping_method_id,name, reset_shipping_date) values(50295656, 'ricky bobby',to_date( '010308', 'mmddyy')) phone_shipping_method(shipping_method_id,name, reset_shipping_date) values(4507655, 'bobby heenan',to_date( '050998', 'mmddyy')) phone_shipping_method(shipping_method_id,name, reset_shipping_date) values(3747547, 'jim-long johnson',to_date( '070969', 'mmddyy')) phone_shipping_method(shipping_method_id,name, reset_shipping_date) values(8432525, 'j joshua johnson',to_date( '070909', 'mmddyy')) phone_shipping_method(shipping_method_id,name, reset_shipping_date) values(943252, 'dusty rhodes',to_date( '100999', 'mmddyy')) select * dual; insert phone_customer(customer_id,first_name, last_name, e_mail, address, city, state , age , zip , phone ) values(508, 'james','buchannen','j@gmail.com','999 james road','los angeles','ca',67,54666,'123456789') phone_customer(customer_id,first_name, last_name, e_mail, address, city, state , age , zip , phone ) values(508534, 'jasmine','buchannen','jasmine21@gmail.com','99056 jumanji road','rainforest,'ca',67,54666,'126956789') phone_customer(customer_id,first_name, last_name, e_mail, address, city, state , age , zip , phone ) values(5432508, 'clyde','buchannen','clydeb57@yahoo.com','65465 james ave','los angeles','ca',67,54667,'125436789') phone_customer(customer_id,first_name, last_name, e_mail, address, city, state , age , zip , phone ) values(7657508, 'jimmy','buchannen','jimmyb@gmail.com','4569 roady road','los angeles','ca',67,54669,'165432789') phone_customer(customer_id,first_name, last_name, e_mail, address, city, state , age , zip , phone ) values(576708, 'bonnie','buchannen','bonniej_buch@aol.com','11999 teeal road','los angeles','ca',67,54676,'176543289') select * dual; insert phone_order(order_id,customer_id, item_id, shipping_method_id, shipping_status_id, quantity, shipping_date, total_due, credit_card_number. credit_card_expiration) values( 432532,5325234,4565,34553,675675,5, to_date( '100999', 'mmddyy'), 56.98,'3456456453334444,'05/17') phone_order(order_id,customer_id, item_id, shipping_method_id, shipping_status_id, quantity, shipping_date, total_due, credit_card_number. credit_card_expiration) values( 45435432,5254354354,47675,3765766553,675757555,5, to_date( '100100', 'mmddyy'), 96.99,'3456456111134444,'05/18') phone_order(order_id,customer_id, item_id, shipping_method_id, shipping_status_id, quantity, shipping_date, total_due, credit_card_number, credit_card_expiration) values( 4542,52554,475,766553,7555,1, to_date( '111111', 'mmddyy'), 96.99,'345645611342133333,'05/11') phone_order(order_id,customer_id, item_id, shipping_method_id, shipping_status_id, quantity, shipping_date, total_due, credit_card_number, credit_card_expiration) values( 42,554,45,765,75,100, to_date( '121212', 'mmddyy'), 76.99,'3456451234566786678,'05/16') phone_order(order_id,customer_id, item_id, shipping_method_id, shipping_status_id, quantity, shipping_date, total_due, credit_card_number, credit_card_expiration) values( 8778872,55878784,4598898,769895,765665,1, to_date( '122317', 'mmddyy'), 50.99,'34564512345555578,'05/115') select * dual; insert phone_item(item_id, brand, model, price, operating_system, screen_size, camera_resolution,network,ram,storage,talk_time,color) values(123344, 'samsung','galaxy',56.78,'android',13.7,'1200x1200','4g'56,120,178,'black') phone_item(item_id, brand, model, price, operating_system, screen_size, camera_resolution,network,ram,storage,talk_time,color) values(123134, 'samsung','galaxy',567.78,'android',13,'120x700','4g',100,100,5178,'green') phone_item(item_id, brand, model, price, operating_system, screen_size, camera_resolution,network,ram,storage,talk_time,color) values(123321, 'samsung','galaxy',656.78,'android',17,'100x100','4g',90,10,1678,'purple') phone_item(item_id, brand, model, price, operating_system, screen_size, camera_resolution,network,ram,storage,talk_time,color) values(12333, 'samsung','galaxy',156.78,'android',3,'200x200','4g',90,20,8178,'brown') phone_item(item_id, brand, model, price, operating_system, screen_size, camera_resolution,network,ram,storage,talk_time,color) values(1233, 'samsung','galaxy',356.78,'android',7,'1200x1200','4g',56,1200,1788,'blue') select * dual;
duplicate column name, missing commas (every column , constraint definition should separated comma), primary key
should not have underline: "primary_key" incorrect. phone_shipping_status table has invalid column name it's primary key , think should shipping_status_id. typo in shiping_status_id , should shipping_status_id, foreign keys phone_customer , phone_item table typed customer , item... , important thing order of tables definition according relations between them re-arranged order. don't think inserts have important issue, didn't check them. it's correct ddl code:
create table phone_customer( customer_id int not null, first_name varchar2(20) not null, last_name varchar2(20) not null, e_mail varchar2(20) not null, address varchar2(20) not null, city varchar (20) not null, state char (2) not null, age int not null, zip int not null, phone varchar(30), constraint phone_customer_pk primary key (customer_id) ); create table phone_item( item_id integer not null, brand varchar2 (20) not null, model varchar2 (20) not null, e_mail varchar2 (20) not null, operating_system varchar2 (20) not null, price decimal(18,2), screen_size decimal(4,2), camera_resolution varchar2(10), network varchar2(4), ram integer not null, storage integer not null, talk_time integer not null, color varchar2(16), constraint phone_item_pk primary key (item_id) ); create table phone_shipping_method( shipping_method_id int not null, name varchar2(20) not null, price decimal(18,2) not null, constraint phone_shipping_method_pk primary key (shipping_method_id) ); create table phone_shipping_status( shipping_status_id int not null, name varchar2(20) not null, reset_shipping_date date not null, constraint phone_shipping_status_pk primary key(shipping_status_id) ); create table phone_order( order_id int not null, customer_id int not null, item_id int not null, shipping_method_id int not null, shipping_status_id int not null, quantity int not null, shipping_date date, total_due decimal(18,2), credit_card_number char(16), credit_card_expiration varchar2(5), constraint phone_order_pk primary key (order_id), constraint fk_customer_id foreign key(customer_id) references phone_customer(customer_id), constraint fk_item_id foreign key(item_id) references phone_item(item_id), constraint fk_shipping_method_id foreign key(shipping_method_id) references phone_shipping_method(shipping_method_id), constraint fk_shipping_status_id foreign key(shipping_status_id) references phone_shipping_status(shipping_status_id) );
Comments
Post a Comment