Last active
August 29, 2015 13:59
-
-
Save return-none/10769175 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> CREATE TABLE products( | |
-> id INT PRIMARY KEY NOT NULL auto_increment, | |
-> name VARCHAR(255) NOT NULL, | |
-> quantity INT NOT NULL | |
-> ); | |
Query OK, 0 rows affected (0.22 sec) | |
mysql> INSERT INTO products(name) VALUES("First product"); | |
Query OK, 1 row affected, 1 warning (0.02 sec) | |
mysql> SELECT * FROM products; | |
+----+---------------+----------+ | |
| id | name | quantity | | |
+----+---------------+----------+ | |
| 1 | First product | 0 | | |
+----+---------------+----------+ | |
1 row in set (0.00 sec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_sql=# CREATE TABLE products( | |
test_sql(# id SERIAL PRIMARY KEY, | |
test_sql(# name VARCHAR(255) NOT NULL, | |
test_sql(# quantity INT NOT NULL | |
test_sql(# ); | |
CREATE TABLE | |
test_sql=# INSERT INTO products(name) VALUES ('First product'); | |
ERROR: null value in column "quantity" violates not-null constraint | |
DETAIL: Failing row contains (1, First product, null). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment