Skip to content

Commit 11da087

Browse files
authored
Create example-sql-statements-that-generate-error-message.sql
1 parent 995a648 commit 11da087

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//Correct syntax
2+
ALTER TABLE specification
3+
ADD CONSTRAINT specification_program_id_fkey
4+
FOREIGN KEY (program_id)
5+
REFERENCES program (id);
6+
7+
//Incorrect syntax; jumbled syntax
8+
ALTER TABLE specification
9+
ADD FOREIGN KEY specification_program_id_fkey
10+
CONSTRAINT(program_id)
11+
REFERENCES program(id);
12+
13+
//Incorrect syntax; wrong punctuation
14+
ALTER TABLE specification (
15+
ADD CONSTRAINT
16+
specification_program_id_fkey
17+
FOREIGN KEY(program_id)
18+
REFERENCES program (id)
19+
);
20+
21+
//Incorrect syntax; a reserved word
22+
ALTER TABLE specification
23+
ADD CONSTRAINT foreign
24+
FOREIGN KEY (program_id)
25+
REFERENCES program (id);
26+
27+
//Incorrect syntax, misspelled keyword REFERENCES
28+
ALTER TABLE specification
29+
ADD CONSTRAINT specification_program_id_fkey
30+
FOREIGN KEY(program_id)
31+
REFERENCE program (id);
32+
33+
//Incorrect syntax, missing closing parenthesis
34+
ALTER TABLE specification
35+
ADD CONSTRAINT specification_program_id_fkey
36+
FOREIGN KEY(program_id
37+
REFERENCES program (id);
38+
39+
//Incorrect syntax; quotes
40+
ALTER TABLE 'specification'
41+
ADD CONSTRAINT specification_program_id_fkey
42+
FOREIGN KEY('program_id')
43+
REFERENCES program ('id');
44+
45+
//Correct syntax; backticks
46+
ALTER TABLE `specification`
47+
ADD CONSTRAINT specification_program_id_fkey
48+
FOREIGN KEY(`program_id`)
49+
REFERENCES program (`id`);
50+
51+
//Incorrect syntax, missing required elements
52+
ALTER TABLE specification
53+
ADD CONSTRAINT specification_program_id_fkey
54+
FOREIGN KEY(program_id);

0 commit comments

Comments
 (0)