Arushi has Published 157 Articles

Difference between HashMap and ConcurrentHashMap in Java

Arushi

Arushi

Updated on 21-Jun-2020 12:18:12

4K+ Views

Following are the notable differences between HashMap and ConcurrentHashMap classes in Java. HashMapConcurrentHashMapSynchronizedHashMap is not synchronized.ConcurrentHashMap is synchronized.Thread SafeHashMap is not thread safe.ConcurrentHashMap is thread safe.Iterator typeHashMap iterator is fail-fast and ArrayList throws ConcurrentModificationException if concurrent modification happens during iteration.ConcurrentHashMap is fail-safe and it will never throw ConcurrentModificationException during iteration.Null valuesHashMap ... Read More

How can we get randomly different set of rows or values each time from MySQL table?

Arushi

Arushi

Updated on 20-Jun-2020 13:14:05

65 Views

When we use RAND() function along with both ORDER BY and LIMIT clause in a query, MySQL returns the different set of rows or values each time. To understand it considers a table ‘Employee’ having the following records −mysql> Select * from Employee; +----+--------+--------+ | ID | Name   | ... Read More

How can it be possible to invert a string in MySQL?

Arushi

Arushi

Updated on 20-Jun-2020 10:52:21

110 Views

MySQL REVERSE() function make it possible to invert a string. Its syntax is as follows −SyntaxREVERSE(STR)Here, STR is a string which we want to invert.Examplemysql> Select REVERSE('MySQL'); +------------------+ | REVERSE('MySQL') | +------------------+ | LQSyM            | +------------------+ 1 row in set (0.05 sec)

How can we use FIND_IN_SET() function with MySQL WHERE clause?

Arushi

Arushi

Updated on 20-Jun-2020 08:45:16

906 Views

When we use FIND_IN_SET() function in WHERE clause then it searches the search string within the given string as specified in the argument and retrieves all the columns from concerned rows. Following is an example to demonstrate it −ExampleIn this example, we are getting the columns from ‘Student’ table where ... Read More

What is the difference between MySQL LENGTH() and CHAR_LENGTH() function?

Arushi

Arushi

Updated on 20-Jun-2020 08:07:49

2K+ Views

Both the functions are string functions and return the number of characters present in the string. But they differ in the concept that CHAR_LENGTH() function measures the string length in ‘characters’ whereas LENGTH() function measures the string length in ‘bytes’. In other words, we can say that CHAR_LENGTH() function is ... Read More

While fetching the data as output, how can I use multiple conditions on same column?

Arushi

Arushi

Updated on 20-Jun-2020 06:23:33

76 Views

Followings are the ways in which we can write a query that returns only records that matches multiple conditions on the same columnBy using ‘OR’ logical operatorAs we know that MySQL ‘OR’ operator compares two expressions and returns TRUE if either of the expression is TRUE. Following example demonstrate that ... Read More

What is MySQL CREATE command? How can we create both database and table with this command?

Arushi

Arushi

Updated on 19-Jun-2020 13:50:23

151 Views

CREATE command is a DDL command which is used to create a table or a database. The syntax for creating table and database with CREATE command is as follows −The syntax for creating a database −Create database database-name;Examplemysql> Create database query; Query OK, 1 row affected (0.04 sec)In the example ... Read More

What is the difference between MySQL PRIMARY KEY and UNIQUE constraint?

Arushi

Arushi

Updated on 19-Jun-2020 13:31:07

517 Views

The following table will provide us the differences between PRIMARY KEY and UNIQUE constraint −PRIMARY KEYUNIQUE Constraint1. Only one Primary key can be created on a table.1. More than one UNIQUE Constraints can be added to a table.2. Primary key creates clustered index by default.2. UNIQUE Constraint creates a non-clustered ... Read More

What happens if I will try to drop PRIMARY KEY constraint from the AUTO_INCREMENT column?

Arushi

Arushi

Updated on 19-Jun-2020 11:53:40

154 Views

As we know the AUTO_INCREMENT column must have the PRIMARY KEY constraint on it also hence when we will try to drop PRIMARY KEY constraint from the AUTO_INCREMENT column the MySQL returns an error message regarding the incorrect table definition. The example below will demonstrate it −ExampleSuppose we have ‘Accounts’ ... Read More

How to get time difference between two timestamps in seconds?

Arushi

Arushi

Updated on 18-Jun-2020 12:28:48

2K+ Views

To get the time difference between two timestamps, try to run the following code. Here, we are calculating the total number of hours, minutes and seconds between two timestamps −ExampleLive Demo           JavaScript Dates                       ... Read More

Advertisements