.sql file failing to execute

时间:2016-02-03 03:44:19

标签: mysql sql

I am in the final steps of submitting a lab for school with the final condition being I have to copy/paste all of my commands with the corresponding question into a sql file named 'lab2.sql'. I've done so but when I attempt to execute the file I receive the follow errors:

source lab2.sql
-bash: /*Name: No such file or directory : No such file or directory
-bash: /*Section:: No such file or directory
-bash: /*Lab: No such file or directory
-bash: /*Can: No such file or directory
-bash: /*Consequently,: No such file or directory
-bash: /*Is: No such file or directory
-bash: /*Use: No such file or directory
-bash: lab2.sql: line 12: syntax error near unexpected token `('
'bash: lab2.sql: line 12: `ALTER TABLE VENDOR ADD CONSTRAINT VENDOR_V_CODE_PK PRIMARY KEY (V_CODE);

Portion of the 'lab2.sql' file.

/*Name*/
/*student id*/
/*Section: B*/
/*Lab 2*/

/*Can the V_CODE column accept null values?: No*/
/*Consequently, is the product entity existence-dependent of the vendor entity?: Yes*/
/*Is the product entity optional to the Vendor entity?: Yes*/

/*Use alter command to add a primary key constraint on V_CODE of the vendor table. Name the constraint as VENDOR_V_CODE_PK: */

ALTER TABLE VENDOR ADD CONSTRAINT VENDOR_V_CODE_PK PRIMARY KEY (V_CODE);

/*Write a SQL command to create the product table (defined below) along with defining the constraints a, b, c and d.  Allow naming of the constraints for b) c) and d) where the */
/*constraint name should start with the table name, underscore, column name, underscore then the symbol for the constraint itself: */

CREATE TABLE PRODUCT (P_CODE VARCHAR(10) NOT NULL PRIMARY KEY, P_DESCRIPT VARCHAR(35) NOT NULL UNIQUE, P_INDATE DATE NOT NULL, P_QOH INTEGER NOT NULL CHECK (P_Id>0), P_MIN INTEGER NOT NULL CHECK (P_Id>0), P_PRICE NUMERIC(9,2) NOT NULL, P_DISCOUNT NUMERIC(5,2) NOT NULL, V_CODE INTEGER NOT NULL);

I apologize if this comes as a silly question. I am only beginning to use sql

0 个答案:

没有答案