Database Articles

Page 168 of 546

How can I check the list of MySQL tables, in the current database we are using, along with table type in the result set?

V Jyothi
V Jyothi
Updated on 20-Jun-2020 166 Views

It can be done with the SHOW FULL TABLES statement. Its Syntax would be as follows −SyntaxSHOW FULL TABLESExampleIn the following example our current database is ‘query’ hence the statement below will show us the table list along with table type in the result set from this database −mysql> SHOW FULL TABLES; +-----------------------------+------------+ | Tables_in_query             | Table_type | +-----------------------------+------------+ | accounts                    | BASE TABLE | | address                     | BASE TABLE | | cars     ...

Read More

Which MySQL query can be used with the help of which we can see the list of MySQL databases?

Nitya Raut
Nitya Raut
Updated on 20-Jun-2020 161 Views

With the help of following MySQL query, we can see the list of MySQL database −mysql> SELECT schema_name FROM information_schema.schemata; +--------------------+ | schema_name        | +--------------------+ | information_schema | | gaurav             | | mysql              | | performance_schema | | query              | | query1             | | sys                | | tutorials          | +--------------------+ 8 rows in set (0.00 sec)We can also use WHERE clause with this query as follows −mysql> SELECT schema_name FROM information_schema.schemata WHERE schema_name LIKE '%schema' OR schema_name LIKE '%s'; +--------------------+ | schema_name        | +--------------------+ | information_schema | | performance_schema | | sys                | | tutorials          | +--------------------+ 4 rows in set (0.00 sec)

Read More

What is the use of CHECK TABLE statement in maintaining the MySQL tables?

Jennifer Nicholas
Jennifer Nicholas
Updated on 20-Jun-2020 194 Views

There may be something wrong which can happen to the database server e.g., the server was shutdown unexpectedly, error while writing data to the hard disk, etc. These situations could make the database operate incorrectly and in the worst case, it can be crashed.With the help of CHECK TABLE statement MySQL allows us to check the integrity of database tables. Its syntax would be as follows −CHECK TABLE table_nameHere, table_name is the name of the table.ExampleWe are running this statement for the table Student_info as follows −mysql> CHECK table student_info\G *************************** 1. row ***************************    Table: query.student_info       ...

Read More

Which MySQL function is used to find first non-NULL value from a list of values?

Ayyan
Ayyan
Updated on 20-Jun-2020 289 Views

We can use MySQL COALESCE() function to get the first non-NULL value as output from a list of values. In other words, this function will check all the values until non-null value found. It can take one or more than one argument. It is having the following syntax:COALESCE(value1, value2, …, valueN)ExampleFollowing is an example to demonstrate it −mysql> Select COALESCE(NULL, NULL, NULL, 'Ram', 'Aarav', NULL); +--------------------------------------------------+ | COALESCE(NULL, NULL, NULL, 'Ram', 'Aarav', NULL) | +--------------------------------------------------+ | Ram                                              | +--------------------------------------------------+ 1 row in set (0.00 sec)

Read More

How MySQL evaluates an empty hexadecimal value?

Arjun Thakur
Arjun Thakur
Updated on 20-Jun-2020 300 Views

Actually, MySQL evaluates an empty hexadecimal value to a zero-length binary string. It can be demonstrated as follows −mysql> Select CHARSET(X''); +--------------+ | CHARSET(X'') | +--------------+ | binary       | +--------------+ 1 row in set (0.00 sec)The above result set shows that the empty hexadecimal value is a binary string. And the result set below shows that it is of length 0.mysql> Select LENGTH(X''); +-------------+ | LENGTH(X'') | +-------------+ | 0           | +-------------+ 1 row in set (0.00 sec)

Read More

How MySQL prevents unauthorized clients from accessing the database system?

Abhinaya
Abhinaya
Updated on 20-Jun-2020 273 Views

MySQL implements a sophisticated access control and privilege system that allows us to create comprehensive access rules for handling client operations and effectively preventing unauthorized clients from accessing the database system.The MySQL access control has two stages when a client connects to the server −Connection verification A client, which connects to the MySQL database server, needs to have a valid username and password. In addition, the host from that the client connects needs to match with the host within the MySQL grant table.Request verificationonce a connection is established successfully, for each statement issued by the client, MySQL checks whether the client ...

Read More

Which tables are used to control the privileges of MySQL database server?

radhakrishna
radhakrishna
Updated on 20-Jun-2020 352 Views

When we install MySQL server, a database named MySQL created automatically. This MySQL database contains five main grant tables with the help of which MySQL server can control the privileges of MySQL database server. These tables are as follows −user tableThis table contains user account and global privileges columns. MySQL uses the user table to either accept or reject a connection from a host. A privilege granted in the user table is effective to all databases on the MySQL server.db tableThis table contains database-level privileges. MySQL uses the db table to determine which database a user can access and from which host. ...

Read More

How to allow a MySQL user account to connect from any host?

vanithasree
vanithasree
Updated on 20-Jun-2020 3K+ Views

It is quite possible to allow a user account to connect from any host. To do so we need to create the user with the help of ‘%’ wild card character after @ character. Its syntax would be as follows −Use mysql; CREATE USER user_name@’%’ IDENTIFIED BY password;Here user_name is the name of the user we wish to make an account for.Password is the password we wish to make for user_account. With the help of this password, MySQL server will identify this user.ExampleIn the given example we are creating a user ‘Gaurav’ by using ‘%’ character so that it can be ...

Read More

How can we remove all the prefixes or suffixes from a given string in MySQL?

Akshaya Akki
Akshaya Akki
Updated on 20-Jun-2020 2K+ Views

MySQL TRIM() function is used to remove all the suffixes or prefixes or both from the string. The working of TRIM() function can be understood with the help of its syntax −SyntaxTRIM([{BOTH | LEADING | TRAILING} [str_to_remove] FROM] string)Here,  the argument BOTH means the prefixes from both left and right to be removed from the string.LEADING argument means that only leading prefixes to be removed.TRAILING argument means that only trailing prefixes to be removed.Str_to_remove is the argument which means the string we want to remove from the string.String argument means the string from which the prefixes have to be removed.Examplemysql> ...

Read More

How can we create a MySQL user account by omitting the hostname?

seetha
seetha
Updated on 20-Jun-2020 494 Views

If we omit the hostname part of the user account, MySQL will accept it and allow the user to connect from any host. Its syntax would be as follows −Use mysql; CREATE USER user_name IDENTIFIED BY password;Here, user_name is the name of the user we wish to take account of.Password is the password we wish to make for user_account. With the help of this password, MySQL server will identify this user.ExampleIn the given example we are creating a user ‘REMOTE’ by omitting the host name.mysql> CREATE USER remote identified by 'password123'; Query OK, 0 rows affected (0.00 sec)The user ‘Remote’ can ...

Read More
Showing 1671–1680 of 5,457 articles
« Prev 1 166 167 168 169 170 546 Next »
Advertisements