Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1.  
  2. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  3.  
  4. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  5.  
  6. MariaDB [(none)]> CREATE DATABASE test4;
  7. Query OK, 1 row affected (0.00 sec)
  8.  
  9. MariaDB [(none)]> use test4
  10. Database changed
  11. MariaDB [test4]> CREATE TABLE tabela(
  12. -> id int primary key auto_increment,
  13. -> suma decimal(10,2));
  14. Query OK, 0 rows affected (0.20 sec)
  15.  
  16. MariaDB [test4]> CREATE TRIGER tabela BEFORE INSERT ON tabela FOR EACH ROW SET @sum=@sum+NEW.suma;
  17. 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 'TRIGER ta
  18. MariaDB [test4]> CREATE TRIGER tabela__bi BEFORE INSERT ON tabela FOR EACH ROW SET @sum=@sum+NEW.suma;
  19. 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 'TRIGER ta
  20. MariaDB [test4]> CREATE TRIGGER tabela BEFORE INSERT ON tabela FOR EACH ROW SET @sum=@sum+NEW.suma;
  21. Query OK, 0 rows affected (0.07 sec)
  22.  
  23. MariaDB [test4]> INSERT INTO tabela VALUES(0, 155),(0, 45), (0,0);
  24. Query OK, 3 rows affected (0.15 sec)
  25. Records: 3 Duplicates: 0 Warnings: 0
  26.  
  27. MariaDB [test4]> SET @sum = 0
  28. -> ;
  29. Query OK, 0 rows affected (0.00 sec)
  30.  
  31. MariaDB [test4]> SELECT @sum AS 'Suma';
  32. +------+
  33. | Suma |
  34. +------+
  35. | 0 |
  36. +------+
  37. 1 row in set (0.00 sec)
  38.  
  39. MariaDB [test4]> INSERT INTO tabela VALUES(0, 155),(0, 45), (0,0);
  40. Query OK, 3 rows affected (0.04 sec)
  41. Records: 3 Duplicates: 0 Warnings: 0
  42.  
  43. MariaDB [test4]> SELECT @sum AS 'Suma';
  44. +--------+
  45. | Suma |
  46. +--------+
  47. | 200.00 |
  48. +--------+
  49. 1 row in set (0.00 sec)
  50.  
  51. MariaDB [test4]> ^A
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement