Karthikeya Boyini has Published 1385 Articles

Can I use InnoDB and MyISAM tables in a single database in MySQL?

karthikeya Boyini

karthikeya Boyini

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

613 Views

Yes, you can use InnoDB and MyISAM tables in one database or combine both of them in a single database. This is the recommended way.Here is the demo of both MyISAM and InnoDB in a one database. The following is the database and both the table types InnoDB and MyISAM. ... Read More

Is there a built-in function for week of the month in MySQL?

karthikeya Boyini

karthikeya Boyini

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

912 Views

There is no standard function to get week of month in MySQL. You need to use the following syntax −SELECT WEEK(yourDateColumnName, 5) - WEEK(DATE_SUB(yourDateColumnName, INTERVAL DAYOFMONTH(yourDateColumnName) - 1 DAY), 5) + 1 AS anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a ... Read More

MySQL Order By date column and integer column, but specify ordering rules of integer column? Is it possible?

karthikeya Boyini

karthikeya Boyini

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

227 Views

You can achieve this with the help of ORDER BY CASE statement. The syntax is as follows −SELECT *FROM yourTableName ORDER BY CASE yourIntegerColumnName1 WHEN 2 THEN 1 ELSE 0 END DESC ,yourDateColumnName ASC;To understand the above syntax, let us create a table. The query to create a table is ... Read More

Iterate through Quintet class in Java Tuples

karthikeya Boyini

karthikeya Boyini

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

151 Views

You can iterate through Quintet class using a loop, like arrays in Java.Let us first see what we need to work with JavaTuples. To work with Quintet class in JavaTuples, you need to import the following package −import org.javatuples.Quintet;Note − Steps to download and run JavaTuples program If you are ... Read More

Java Program to get Temporal Queries precision

karthikeya Boyini

karthikeya Boyini

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

171 Views

To get Temporal Queries precision, use the TemporalQuery interface with the precision() method of the TemporalQueries −TemporalQueryprecision = TemporalQueries.precision(); Get the precision for LocalDate: LocalDate.now().query(precision) Get the precision for LocalTime: LocalTime.now().query(precision) Get the precision for YearMonth: YearMonth.now().query(precision) Get the precision for Year: Year.now().query(precision)Exampleimport java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.Year; ... Read More

Why SHOW DBS does not show my databases in MongoDB?

karthikeya Boyini

karthikeya Boyini

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

4K+ Views

This SHOW DBS command won’t show the databases because you may have not created a document for a collection. If you will create document for a collection then the created database will be visible.Let us implement the above concept and create a database −> use web; switched to db webFollowing ... Read More

Change max_heap_table_size value in MySQL?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

The max_heap_table_size is a system variable that has both read/write property.Initially, max_heap_table_size has size 16 MB. First, check the value of max_heap_table_size, which is in bytes.The query is as follows −mysql> select @@max_heap_table_size;The following is the output −+-----------------------+ | @@max_heap_table_size | +-----------------------+ | 16777216 ... Read More

How to get number of quarters between two dates in Java

karthikeya Boyini

karthikeya Boyini

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

700 Views

Let’s say we have the following two dates −LocalDate.of(2019, 3, 20); LocalDate.of(2019, 10, 25);To get the number of quarters between the above two dates, use the QUARTER_YEARS −IsoFields.QUARTER_YEARS.between(LocalDate.of(2019, 3, 20), LocalDate.of(2019, 10, 25));Exampleimport java.time.LocalDate; import java.time.temporal.IsoFields; public class Demo {    public static void main(String[] args) {       ... Read More

How to apply a condition only if field exists in MongoDB?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

You can use $or operator for this. Let us first create a collection with documents −> db.applyConditionDemo.insertOne({"StudentName":"Larry", "StudentAge":21, "StudentMarks":45}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb80b78623186894665ae36") } > db.applyConditionDemo.insertOne({"StudentName":"Sam", "StudentAge":23, "StudentMarks":55}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb80b87623186894665ae37") } > db.applyConditionDemo.insertOne({"StudentName":"David", "StudentAge":21, "StudentMarks":65}); {    "acknowledged" ... Read More

Rename all tables and columns to lower case in MySQL?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

You can achieve this with the help of INFORMATION_SCHEMA.COLUMNS. The syntax is as follows −SELECT CONCAT('ALTER TABLE ', TABLE_NAME, ' CHANGE `', COLUMN_NAME, '` `', LOWER(COLUMN_NAME), '` ', COLUMN_TYPE, ';') AS anyAliasName FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ‘yourDatabaseName’;Now use the database which has two tables. The database name is as ... Read More

Advertisements