Şöyle yaparız
CREATE EVENT myeventON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOURDOUPDATE myschema.mytable SET mycol = mycol + 1;
CREATE EVENT myeventON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOURDOUPDATE myschema.mytable SET mycol = mycol + 1;
When using the soft delete mechanism on the database, you might run into a situation where a record with a unique constraint was deleted and you want to reuse the unique value.
If your database does not have partial indexes, e.g. MySQL, you could use a different approach with virtual columns.Considering that in most SQL databases, the UNIQUE constraint ignores NULL values, we can use a composite key in the UNIQUE constraint that includes a nullable column that indicates if a record was deleted.To do so, we can add a virtual column not_archived that gets its value from the soft delete column.
ALTER TABLE users ADD not_archived BOOLEAN GENERATED ALWAYS AS (IF(deleted_at IS NULL, 1, NULL)) VIRTUAL;
This will result in a field that gets automatically updated according to the deleted_at column. It will have the value 1 when the record is not deleted (deleted_at=NULL), else it will be NULL. Now we just need to add it to the UNIQUE constraint. Remember to drop the old constraint.
ALTER TABLE users ADD CONSTRAINT UNIQUE (email, not_archived);
For instance, the UUID() MySQL function returns a version 1 UUID number.And the Java UUID.randomUUID() function returns a version 4 UUID number.
db <-- Ben yarattım information_schema mysql <-- MySQL kurulumu ile geliyor performance_schema sys
The MySQL installation comes with default databases. One of the database is named 'mysql'.
CREATE TABLE IF NOT EXISTS db.myworker (...);
1. Eğer bağlantı şöyle ise yani veri tabanı belirtilmemişsetry (Connection connection = ...;ResultSet tables = connection.getMetaData().getTables( connection.getCatalog(),null,null,new String[]{"TABLE", "VIEW"})) {...}
jdbc:mysql://localhost:3306/
jdbc:mysql://localhost:3306/db
try (Connection connection = ...;ResultSet tables = connection.getMetaData().getTables( null,null,null,new String[]{"TABLE", "VIEW"})) {...}
jdbc:mysql://localhost:3306/
jdbc:mysql://localhost:3306/db
mysql> explain analyze select * from employee1 where id = 3456; +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | EXPLAIN | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | -> Filter: (employee1.id = 3456) (cost=1989 rows=1965) (actual time=5.24..29.3 rows=1 loops=1) -> Table scan on employee1 (cost=1989 rows=19651) (actual time=0.0504..27.3 rows=20000 loops=1) | +--------------------------------------------------------------------------------------------------------
CREATE INDEX index1 ON employee1 (FirstName);
mysql> explain analyze select * from employee1 where FirstName = 'user-13456'; +-------------------------------------------------------------------------------------------------------------------------------------+ | EXPLAIN | +-------------------------------------------------------------------------------------------------------------------------------------+ | -> Index lookup on employee1 using index1 (FirstName='user-13456') (cost=0.35 rows=1) (actual time=0.0594..0.0669 rows=1 loops=1) | +-------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
Örnek Şöyle yaparız CREATE EVENT myevent ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO UPDATE myschema.mytable SET myc...