Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Dúvida

Antes de criar a nova stored procedure, o instrutor falou que se ele rodasse o código do jeito que tava, a antiga seria apagada (por conta do DROP do início). Porém o código é "drop IF EXISTS nomedaprocedure". Como a nova possui um nome diferente, pois leva a palavra "erro" no final, o drop realmente exlcuiria a antiga?

2 respostas
solução!

Susany,

Sim, pois o "IF EXISTS" explicita que fará o comando "SE EXISTIR".

Por favor, leia mais sobre o assunto:

==========================================================

MySQL DROP TABLE statement syntax

The IF EXISTS option conditionally drop a table only if it exists. If you drop a non-existing table with the IF EXISTS option, MySQL generates a NOTE, which can be retrieved using the SHOW WARNINGS statement.

Note that the DROP TABLE statement only drops tables. It doesn’t remove specific user privileges associated with the tables.

https://www.mysqltutorial.org/mysql-drop-table

==========================================================

DROP TABLE IF EXISTS in MySQL

In MySQL, we can use the IF EXISTS clause of the DROP TABLE statement to check whether the table exists or not before dropping it.

https://database.guide/drop-table-if-exists-in-mysql/

==========================================================

16.4.1.9 Replication of DROP ... IF EXISTS Statements

The DROP DATABASE IF EXISTS, DROP TABLE IF EXISTS, and DROP VIEW IF EXISTS statements are always replicated, even if the database, table, or view to be dropped does not exist on the source. This is to ensure that the object to be dropped no longer exists on either the source or the replica, once the replica has caught up with the source.

DROP ... IF EXISTS statements for stored programs (stored procedures and functions, triggers, and events) are also replicated, even if the stored program to be dropped does not exist on the source.

https://dev.mysql.com/doc/refman/5.7/en/replication-features-drop-if-exists.html

==========================================================

thisPointer

Programming Tutorials

MySQL IF EXISTS DROP Table

Database, Mysql / By Ritika

https://thispointer.com/mysql-if-exists-drop-table/

==========================================================

MySQL - Drop view if exists

Created by: Marcino

In this article, we would like to show you how to DROP VIEW IF EXISTS in MySQL.

DROP VIEW IF EXISTSview_name;

Practical example

https://dirask.com/posts/MySQL-Drop-view-if-exists-DZXxej

==========================================================

[]'s,

Fabio I.

Ah sim, dei uma confundida nos termos aqui. Já entendi. Obrigada!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software