How to drop all tables from a database with one SQL query?

Use the INFORMATION_SCHEMA.TABLES view to get the list of tables. Generate Drop scripts in the select statement and drop it using Dynamic SQL: Sys.Tables Version Note: If you have any foreign Keys defined between tables then first run the below query to disable all foreign keys present in your database. For more information, check here.

mysql Foreign key constraint is incorrectly formed error

I ran into this same problem with HeidiSQL. The error you receive is very cryptic. My problem ended up being that the foreign key column and the referencing column were not of the same type or length. The foreign key column was SMALLINT(5) UNSIGNED and the referenced column was INT(10) UNSIGNED. Once I made them both the same … Read more

How do you trouble shoot a “Data type mismatch in criteria expression” error in MS Access 2010?

The criteria expression is the part of the query containing the conditions, as in WHERE <condition>. Look at those specifically. The error message means you’re comparing two things (this equals that, or this less than that, etc.) that are of two different, and incompatible types (comparing a number to a string, for example). You can find … Read more

How do I import an SQL file using the command line in MySQL?

Try: Check MySQL Options. Note 1: It is better to use the full path of the SQL file file.sql. Note 2: Use -R and –triggers to keep the routines and triggers of original database. They are not copied by default. Note 3 You may have to create the (empty) database from MySQL if it doesn’t exist already and the exported SQL don’t contain CREATE DATABASE (exported … Read more

What does SQL Select symbol || mean?

|| represents string concatenation. Unfortunately, string concatenation is not completely portable across all sql dialects: ansi sql: || (infix operator) mysql: concat ( vararg function ). caution: || means ‘logical or’ (It’s configurable, however; thanks to @hvd for pointing that out) oracle: || (infix operator), concat ( caution: function of arity 2 only ! ) postgres: || (infix operator) sql server: + (infix operator), concat ( vararg function ) sqlite: || (infix operator) hopefully the confusion is complete … Read more

How to reset AUTO_INCREMENT in MySQL

You can reset the counter with: For InnoDB you cannot set the auto_increment value lower or equal to the highest current index. (quote from ViralPatel): Note that you cannot reset the counter to a value less than or equal to any that have already been used. For MyISAM, if the value is less than or equal to the maximum value … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)