Karthikeya Boyini has Published 2193 Articles

Select current time with MySQL now() and convert it to GMT 0?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

527 Views

You can use utc_timestamp() for this. Following is the syntax −SELECT utc_timestamp();Let us check the current time using now().Following is the query −mysql> select now();This will produce the following output −+---------------------+ | now() | +---------------------+ | ... Read More

Create Septet Tuple from another collection in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

102 Views

The fromCollection() method is used in JavaTuples to create Septet Tuple from another collection. We will see an example of creating a Septet Tuple using List collection.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following ... Read More

MySQL add “prefix” to every column?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

1K+ Views

To create a view only if it does not already exist, you can use the following syntax −CREATE OR REPLACE VIEW yourViewName AS SELECT *FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table createViewDemo    -> ( ... Read More

LocalDate minusDays() Method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

249 Views

An immutable copy of the LocalDate where the days are subtracted from it can be obtained using the minusDays() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of days to be subtracted and it returns the instant with the subtracted days.A program ... Read More

How to check if a table exists in MySQL and create if it does not already exist?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

1K+ Views

If you try to create a table and the table name already exist then MySQL will give a warning message. Let us verify the concept.Here, we are creating a table that already exist −mysql> CREATE TABLE IF NOT EXISTS DemoTable    (    CustomerId int,    CustomerName varchar(30),    CustomerAge ... Read More

Command to check read/write ratio in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

762 Views

To check the read/write ratio, you need to use SHOW STATUS command. This will give all the ratios.Case 1 − The syntax is as follows to get the read/write ratio −SHOW STATUS LIKE ‘Com_%’;Case 2 − If you want the insert, update, select and delete ratio, use the below syntax ... Read More

JavaTuples addAtX() method for Triplet class

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

111 Views

The addAtX() method is used to add a value to the Triplet Tuple. The index can be set here with the X i.e. the place where the value gets added.Let us first see what we need to work with JavaTuples. To work with Triplet class in JavaTuples, you need to ... Read More

LocalDate minusMonths() Method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

852 Views

An immutable copy of the LocalDate where the months are subtracted from it can be obtained using the minusMonths() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of months to be subtracted and it returns the instant with the subtracted months.A program ... Read More

How to avoid inserting duplicate rows in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

515 Views

To avoid inserting duplicate rows in MySQL, you can use UNIQUE(). The syntax is as follows −ALTER TABLE yourTableName ADD UNIQUE(yourColumnName1, yourColumnName2, ...N);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table avoidInsertingDuplicateRows    -> (    -> Id ... Read More

How to sort List in descending order using Comparator in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

696 Views

Let us first create an ArrayList −ArrayListarrList = new ArrayList(); arrList.add(10); arrList.add(50); arrList.add(100); arrList.add(150); arrList.add(250);Use Comparators interface to order in reverse order with reverseOrder() −Comparator comparator = Collections.reverseOrder(); Now, sort with Collections: Collections.sort(arrList, comparator);Example Live Demoimport java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class Demo {    public static void main(String[] args) ... Read More

Advertisements