SHOW WARNINGS is a diagnostic statement that displays information about the conditions (errors, warnings, and notes) resulting from executing a statement in the current session. Warnings are generated for DML statements such as INSERT, UPDATE, and LOAD DATA as well as DDL statements such as CREATE TABLE and ALTER TABLE.
SHOW WARNINGS;
Setting environment for using XAMPP for Windows.
venkat@VENKAT-PC c:\xampp
# mysql -h localhost -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.37-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| student |
| test |
| vlrinst |
+--------------------+
7 rows in set (0.07 sec)
MariaDB [(none)]> USE vlrinst;
Database changed
MariaDB [vlrinst]> SHOW TABLES;
+-------------------+
| Tables_in_vlrinst |
+-------------------+
| faculty |
| ram |
+-------------------+
2 rows in set (0.00 sec)
MariaDB [vlrinst]> desc ram;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | varchar(30) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.07 sec)
MariaDB [vlrinst]> desc ram;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | varchar(30) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.02 sec)
MariaDB [vlrinst]> insert into ram values(999,"dfjsfjdshfkjsdhfjksdhfkjdshfjksdh
fkjsdhfjkdhsfjkhdsfjhdsjkfhdsjkfhkdsjfhj");
Query OK, 1 row affected, 1 warning (0.12 sec)
MariaDB [vlrinst]> select * from ram;
+------+--------------------------------+
| id | name |
+------+--------------------------------+
| 2 | prav |
| 3 | rame |
| 999 | dfjsfjdshfkjsdhfjksdhfkjdshfjk |
+------+--------------------------------+
3 rows in set (0.08 sec)
MariaDB [vlrinst]> show warnings;
Empty set (0.00 sec)
MariaDB [vlrinst]> insert into ram values(999,"dfjsfjdshfkjsdhfjksdhfkjdshfjksdh
fkjsdhfjkdhsfjkhdsfjhdsjkfhdsjkfhkdsjfhj");
Query OK, 1 row affected, 1 warning (0.07 sec)
MariaDB [vlrinst]> show warnings;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1265 | Data truncated for column 'name' at row 1 |
+---------+------+-------------------------------------------+
1 row in set (0.00 sec)
MariaDB [vlrinst]> insert into ram values(32947938274983274,"kiran");
Query OK, 1 row affected, 1 warning (0.06 sec)
MariaDB [vlrinst]> show warnings;
+---------+------+---------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------+
| Warning | 1264 | Out of range value for column 'id' at row 1 |
+---------+------+---------------------------------------------+
1 row in set (0.00 sec)
MariaDB [vlrinst]> select * from ram;
+------------+--------------------------------+
| id | name |
+------------+--------------------------------+
| 2 | prav |
| 3 | rame |
| 999 | dfjsfjdshfkjsdhfjksdhfkjdshfjk |
| 999 | dfjsfjdshfkjsdhfjksdhfkjdshfjk |
| 2147483647 | kiran |
+------------+--------------------------------+
5 rows in set (0.00 sec)
MariaDB [vlrinst]> insert into ram values(,"kiran1");
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near '"ki
ran1")' at line 1
MariaDB [vlrinst]> insert into ram values(22);
ERROR 1136 (21S01): Column count doesn't match value count at row 1
MariaDB [vlrinst]> insert into ram values(22,);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near ')'
at line 1
MariaDB [vlrinst]> insert into ram values(22,45495498);
Query OK, 1 row affected (0.04 sec)
MariaDB [vlrinst]> show warnings;
Empty set (0.00 sec)
MariaDB [vlrinst]> select * from ram;
+------------+--------------------------------+
| id | name |
+------------+--------------------------------+
| 2 | prav |
| 3 | rame |
| 999 | dfjsfjdshfkjsdhfjksdhfkjdshfjk |
| 999 | dfjsfjdshfkjsdhfjksdhfkjdshfjk |
| 2147483647 | kiran |
| 22 | 45495498 |
+------------+--------------------------------+
6 rows in set (0.00 sec)
MariaDB [vlrinst]> insert into ram values("ram","u33");
Query OK, 1 row affected, 1 warning (0.06 sec)
MariaDB [vlrinst]> show warnings;
+---------+------+---------------------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------------------+
| Warning | 1366 | Incorrect integer value: 'ram' for column 'id' at row 1 |
+---------+------+---------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [vlrinst]>
MariaDB [vlrinst]> select * from ram;
+------------+--------------------------------+
| id | name |
+------------+--------------------------------+
| 2 | prav |
| 3 | rame |
| 999 | dfjsfjdshfkjsdhfjksdhfkjdshfjk |
| 999 | dfjsfjdshfkjsdhfjksdhfkjdshfjk |
| 2147483647 | kiran |
| 22 | 45495498 |
| 0 | u33 |
+------------+--------------------------------+
7 rows in set (0.00 sec)
MariaDB [vlrinst]> insert into ram values(123,kiran);
ERROR 1054 (42S22): Unknown column 'kiran' in 'field list'
MariaDB [vlrinst]> insert into ram values(123,'kiran');
Query OK, 1 row affected (0.07 sec)
MariaDB [vlrinst]> insert into ram values(123,876767);
Query OK, 1 row affected (0.06 sec)
MariaDB [vlrinst]>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.