karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 122 of 143

How to fix poor performance of INFORMATION_SCHEMA.key_column_usage in MySQL?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 232 Views

You can use GLOBAL variable as shown below −SET global innodb_stats_on_metadata =0;After including the above syntax, the INFORMATION_SCHEMA.key_column_usage will take less time and that would improve the performance.The query is as follows −mysql> set global innodb_stats_on_metadata =0; Query OK, 0 rows affected (0.00 sec) mysql> SELECT REFERENCED_TABLE_NAME,TABLE_NAME,COLUMN_NAME,CONSTRAINT_SCHEMA -> FROM INFORMATION_SCHEMA.key_column_usage;The following is the output −It returns 674 rows in 0.28 seconds.

Read More

Correctly implement the AND condition in MySQL

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 149 Views

To implement AND condition, the syntax is as follows −select *from yourTableName where yourColumnName1 = yourValue1 AND yourColumnName2 = yourValue2;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table MySQLANDConditionDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100),    -> Age int    -> ); Query OK, 0 rows affected (0.80 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into MySQLANDConditionDemo(Name, Age) values('Larry', 23); Query OK, 1 row affected (0.11 sec) mysql> ...

Read More

How do I get the average string length in MySQL?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 1K+ Views

To get the average string length in MySQL, we will work around a query that gets rows from 1 to 10 and displays the result.Let us first create a table. The query to create a table is as follows −mysql> create table AverageString -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Value varchar(20) -> ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into AverageString(Value) values('MySQL Query'); Query OK, 1 row ...

Read More

What does % stand for in host column and how to change user's password?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 420 Views

The localhost means you can access from same machine while from % the remote host access is possible. The syntax is as follows to change the user password.SET PASSWORD FOR 'yourUserName'@'localhost' ='yourPassword';First check the user and host from MySQL.user table. The query is as follows −mysql> select user, host from MySQL.user;Here is the output −+------------------+-----------+ | user             | host      | +------------------+-----------+ | Bob              | %       | | Manish | % ...

Read More

Set Optimal MySQL configuration in my.cnf?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 279 Views

First, you need to open my.cnf file. The following is the query to get the directory location of the config file on Windows −mysql> select @@datadir;Output+---------------------------------------------+ | @@datadir | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)Here is the snapshot of the directory −Now open my.cnf file. The snapshot is as follows −If you want to add more data to cache, ...

Read More

How do you get the last access (and/or write) time of a MySQL database?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 2K+ Views

To get the last access time, try the following syntax −SELECT update_time FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'yourDatabaseName' AND table_name = 'yourTableName'The above syntax gives the last access information about MyISAM engine type.Here, our database is ‘business’ and we will be using the table with the name ‘twoprimarykeytabledemo'.To get last access time of MySQL database, use the following query.Case 1 − The query is as follows −mysql> SELECT update_time    -> FROM INFORMATION_SCHEMA.TABLES    -> WHERE table_schema = 'business'    -> AND table_name = 'twoprimarykeytabledemo';The output is as follows −+---------------------+ | UPDATE_TIME ...

Read More

How to check whether a stored procedure exist in MySQL?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 924 Views

Let us first create a stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE ExtenddatesWithMonthdemo(IN date1 datetime, IN NumberOfMonth int )    -> BEGIN    -> SELECT DATE_ADD(date1, INTERVAL NumberOfMonth MONTH) AS ExtendDate;    -> END;    -> // Query OK, 0 rows affected (0.20 sec) mysql> DELIMITER ;Now you check whether the stored procedure exists with the help SHOW CREATE command.The query is as follows −mysql> SHOW CREATE PROCEDURE ExtenddatesWithMonthdemo; The following is the output displaying the details of the stored procedure we created above: +--------------------------+--------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+ | Procedure                | sql_mode ...

Read More

How to upgrade MySQL server from command line?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 3K+ Views

First, you need to open the CMD with the help of shortcut key Windows+R key.After typing cmd, press the OK button. On pressing, you will get a command prompt. The screenshot is as follows −After that, you need to reach the /bin directory. Follow the below instructions. If you are a Windows user, then use the below query to reach the /bin directory.The query is as follows −mysql> select @@datadir;The following is the output displaying the path −+---------------------------------------------+ | @@datadir ...

Read More

C++ Program to Implement Rolling Hash

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 1K+ Views

Rolling hash is a hash function in which the input is hashed in a window that moves through the input.Rabin-Karp is popular application of rolling hash. The rolling hash function proposed by Rabin and Karp calculates an integer value. For a string the integer value is numeric value of a string.The Rabin–Karp string search algorithm is often explained using a very simple rolling hash function that only uses multiplications and additions −H=c1ak-1+c2ak-2+….+ cka0.Where, a is a constant, and c1, c2….ck are the input characters. In order to manipulate Huge value of H, mod n is done.AlgorithmBegin    Declare a constant ...

Read More

How to flush output stream after writing bytes

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 554 Views

Let us first crate OutputStream with file input.txt −FileOutputStream fileStream = new FileOutputStream("E:/input.txt"); DataOutputStream dataStream = new DataOutputStream(fileStream);Now, the writeBytes() method writes out the string to the underlying output stream as a sequence of bytes.dataStream.writeBytes("Demo text!");Flush the output stream −dataStream.flush();The following is an example. Here, our file is “E:/input.txt” and at the end we are flushing the output stream −Exampleimport java.io.DataOutputStream; import java.io.FileOutputStream; public class Demo {    public static void main(String[] args) throws Exception {       FileOutputStream fileStream = new FileOutputStream("E:/input.txt");       DataOutputStream dataStream = new DataOutputStream(fileStream);       dataStream.writeBytes("Demo text!");       ...

Read More
Showing 1211–1220 of 1,421 articles
« Prev 1 120 121 122 123 124 143 Next »
Advertisements