MySQL 8 get the currently used (default) database name [duplicate] - mysql

This question already has answers here:
How to determine which database is selected
(5 answers)
Closed 2 years ago.
You may use USE statement
USE <db_name>
to use the named database as the default
but how to get the name of the database that is currently used?
So if USE sets the db name, is there a kind of GET or SELECT statement to read database that was set as the default?
Suppose you get a result of a query after many hours and you forgot what particular database that query was targeting. It would be helpful to be able to ask for the default database name to know which database that query result refers to.

You can just do:
select database()

Related

Connect to a database on MySQL [duplicate]

This question already has answers here:
Selecting a database in mysql with spaces in its name
(6 answers)
Closed 3 years ago.
I just signed in to MySQL and am trying to connect to a database so that I can begin to write tables. My research understanding is that you use "use" followed by the database name, and end with ;
The database name that I am trying to connect to is 3 words with space in between them (i.e., A B Database)
When I try use A B Database; it says there is a syntax error at the B. Any reasons why this may be happening?
Surround the database name with back-ticks:
e.g.
create database `abc de f`;
use `abc de f`;
The back-tick character is used to surround database, table or field names that contains a space.

MySQL ignore database case [duplicate]

This question already has answers here:
Are table names in MySQL case sensitive?
(5 answers)
Closed 5 years ago.
Is there a way to ignore database (not table or column) name case in mysql? I have database FOO but I'd like to refer to it as foo.some_table or FOO.some_table. Setting lower_case_table_names doesn't seem to work. I've even migrated to a new database and recreated the database with name foo but now FOO.some_table doesn't work. Is this possible?
You can find the answer to your question here: link. It's article in MySQL documentary about identifier case sensitivity.

Make Table Names and Column Names Case Insensitive in MySQL [duplicate]

This question already has answers here:
Are table names in MySQL case sensitive?
(5 answers)
Closed 6 years ago.
I would like to be able to query the table Users and its columns UserName and Email case insensitively:
select username, email from users;
I know MySQL is case-insensitive for strings by default--that is not my question. I would like to query case-insensitive table and column names.
The SQL Server environment I work allows me to do so but don't know how to do so in MySQL.
You can use the lower_case_table_names system variable as described in Documentation. You can set this variable to the allowed value on start of mysqld or even in my.cnf config file

MySQL command to Extract DDL and DML and Exclude tables which are not required? [duplicate]

This question already has answers here:
How to skip certain database tables with mysqldump?
(11 answers)
Closed 9 years ago.
I have a db and looking for a mysql commands to extract Extract DDL and DML and Exclude tables which are not required
could you please let me know how we can do it via command prompt?
Thanks,
Kathir
Mysqldump:
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
able to dump DDL/DML and has option for exclude list of tables:
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_ignore-table

When working with access and mysql is there a way to view which queries are used to generate a pivot table? [duplicate]

This question already has an answer here:
How to retrieve the sql code from an Excel 2007 PivotTable
(1 answer)
Closed 3 years ago.
How can I determine which sql queries are being used to generate the data?
MySql has a "processlist" command which can show you the running queries. If you can catch the query as it runs you could see what it's doing.