Last active
August 29, 2015 14:00
-
-
Save return-none/11152572 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
MariaDB [(none)]> create database testing; | |
Query OK, 1 row affected (0.00 sec) | |
MariaDB [(none)]> use testing; | |
Database changed | |
MariaDB [testing]> 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.01 sec) | |
MariaDB [testing]> INSERT INTO products(name) VALUES("First product"); | |
Query OK, 1 row affected, 1 warning (0.00 sec) | |
MariaDB [testing]> SELECT * FROM products; | |
+----+---------------+----------+ | |
| id | name | quantity | | |
+----+---------------+----------+ | |
| 1 | First product | 0 | | |
+----+---------------+----------+ | |
1 row in set (0.00 sec) | |
MariaDB [testing]> ALTER TABLE products ADD COLUMN price DECIMAL(6,2) NOT NULL; | |
Query OK, 1 row affected (0.03 sec) | |
Records: 1 Duplicates: 0 Warnings: 0 | |
MariaDB [testing]> SELECT * FROM products; | |
+----+---------------+----------+-------+ | |
| id | name | quantity | price | | |
+----+---------------+----------+-------+ | |
| 1 | First product | 0 | 0.00 | | |
+----+---------------+----------+-------+ | |
1 row in set (0.00 sec) | |
MariaDB [testing]> UPDATE products SET price=100 WHERE id=1; | |
Query OK, 1 row affected (0.01 sec) | |
Rows matched: 1 Changed: 1 Warnings: 0 | |
MariaDB [testing]> SELECT * FROM products; | |
+----+---------------+----------+--------+ | |
| id | name | quantity | price | | |
+----+---------------+----------+--------+ | |
| 1 | First product | 0 | 100.00 | | |
+----+---------------+----------+--------+ | |
1 row in set (0.00 sec) | |
MariaDB [testing]> ALTER TABLE products MODIFY price DECIMAL(2,2) NOT NULL; | |
Query OK, 1 row affected, 1 warning (0.01 sec) | |
Records: 1 Duplicates: 0 Warnings: 1 | |
MariaDB [testing]> SELECT * FROM products; | |
+----+---------------+----------+-------+ | |
| id | name | quantity | price | | |
+----+---------------+----------+-------+ | |
| 1 | First product | 0 | 0.99 | | |
+----+---------------+----------+-------+ | |
1 row in set (0.00 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment