Found 4219 Articles for MySQLi

Difference between Schema and Database in MySQL?

George John
Updated on 24-Jun-2020 14:07:57

4K+ Views

In MySQL, schema is synonymous with database. As the query is written to create the database, similarly the query can be written to create the schema.Logical structure can be used by the schema to store data while memory component can be used by the database to store data. Also, a schema is collection of tables while a database is a collection of schema.To clarify this concept, a database and a schema are created. The steps for this are as follows −First, a database is created with the following syntax −create database yourDatabaseName;The above syntax is used in a query as ... Read More

How can I stop running a MySQL query?

Chandu yadav
Updated on 24-Jun-2020 14:09:41

899 Views

Before stopping a running query of MySQL, first we need to see how many processes are running with the help of show command.The query for that is given as follows −mysql> show processlist;After executing the above query, we will get the output with some id’s. This is given as follows −+----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-----------------+-----------------+----------+---------+-------+------------------------+------------------+ | 4 | event_scheduler | localhost | NULL | Daemon | 71034 | Waiting on empty queue | NULL | | 8 | Manish | localhost:53496 | business | Query | ... Read More

How can I find non-ASCII characters in MySQL?

Ankith Reddy
Updated on 24-Jun-2020 14:10:12

1K+ Views

Non ASCII characters are characters such as the pound symbol(£), trademark symbol, plusminus symbol etc. To find the non-ASCII characters from the table, the following steps are required −First a table is created with the help of the create command which is given as follows −mysql> CREATE table NonASciiDemo -> ( -> NonAScii varchar(100) -> ); Query OK, 0 rows affected (0.61 sec)After that the records are inserted into the table with the help of the insert command which is as follows −mysql> INSERT into NonASciiDemo values('-, -'); Query OK, 1 row affected (0.18 sec) mysql> INSERT into NonASciiDemo ... Read More

Which one is better to insert NULL or empty string in MySQL?

Arjun Thakur
Updated on 24-Jun-2020 14:10:49

2K+ Views

In innoDB, NULL occupies less space as compared to empty string. Also, the NULL length is null while length of the empty string is 0.To understand this, a table is created with the help of create command which is given as follows −mysql> CREATE table DemoEmptyAndNULL -> ( -> Message varchar(100) -> ); Query OK, 0 rows affected (0.49 sec)After creating the table successfully, an empty record is inserted into the table with the help of insert command which is as follows −mysql> INSERT into DemoEmptyAndNULL values(' '); Query OK, 1 row affected (0.17 sec)After inserting the record, we can ... Read More

How do I check if a column is empty or null in MySQL?

George John
Updated on 02-Sep-2023 15:49:47

44K+ Views

To check if a column is empty or null , we can use the WHERE clause with IS NULL and for empty we can use the condition ' ' i.e., empty space. The steps required for this are as folllows: First a table is created with the help of CREATE command as follows −mysql> CREATE table ColumnValueNullDemo -> ( -> ColumnName varchar(100) -> ); Query OK, 0 rows affected (0.61 sec)An empty value is inserted into the table using INSERT command. This is given below −mysql> INSERT into ColumnValueNullDemo values(' '); Query OK, 1 row affected (0.14 sec)After that, the ... Read More

Find records from one MySQL table which don't exist in another?

Chandu yadav
Updated on 24-Jun-2020 14:12:31

655 Views

To find the records from one MySQL table which don’t exist in another table we can use the subquery for the table which does not have the records. This can be better understood using the given steps −First a table is created using the create command. The table name is ‘PresentHistory’ and it has two columns. This is given as follows −mysql> CREATE table PresentHistory -> ( -> HisID int, -> HisName varchar(100) -> ); Query OK, 0 rows affected (0.54 sec)After creating the table, some records are inserted that will be present in the second table as well. This ... Read More

ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'?

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

11K+ Views

In the system, the root is defined by another name as well as password. Then the user is created as a root with the help of the create command. This will result in the ERROR 1396. The query for this is given as follows − mysql> create user 'root'@'localhost' identified by 'root123'; After executing the above query, the following error is obtained − ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost' The user can be created with another name and password successfully. This is given as follows − mysql> create user 'John'@'localhost' identified by ... Read More

How to find out port of MySQL Server?

Arjun Thakur
Updated on 24-Jun-2020 14:13:51

6K+ Views

To find the port of the MySQL server, the command show can be used. Its syntax is as follows −show variables where variable_name=’port’;The above syntax is used to get the port number of the MySQL server using the following query −mysql> show variables where variable_name = 'port';After executing the above command, port of MySQL server is obtained as 3306. This can be seen in the following output −+---------------+-------+ | Variable_name | Value | +---------------+-------+ | port          | 3306  | +---------------+-------+ 1 row in set (0.01 sec)Alternatively, the system variable @@port can also be used to find ... Read More

What is the MySQL VARCHAR max size?

George John
Updated on 24-Jun-2020 14:15:23

4K+ Views

The MySQL version before 5.0.3 was capable of storing 255 characters but from the version 5.0.3 , it is capable of storing 65, 535 characters.MySQL official documentation states −The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65, 535 bytes, which is shared among all columns) and the character set used. For example, utf8 characters can require up to three bytes per character, so a VARCHAR column that uses the utf8 character set can be declared to be a maximum of 21, 844 characters. Keep in mind that the limitation of ... Read More

What is the best data type to store money values in MySQL?

Chandu yadav
Updated on 24-Jun-2020 14:16:00

5K+ Views

We can store the money values in MySQL in decimal(value1, value2). Here, value1 is the total range including value2. The value2 specifies the number of digits after the decimal point. To understand this concept, the steps are given below.First a table is created using the create command.mysql> CREATE table MoneyDemo -> ( -> Id int, -> Money decimal(10, 2) -> ); Query OK, 0 rows affected (0.46 sec)As can be seen from the above command, the decimal value has 10 digits only and also 2 digits only after the decimal point.After creating the table, some records are inserted with the ... Read More

Advertisements