Daniol Thomas has Published 209 Articles

Adding new enum column to an existing MySQL table?

Daniol Thomas

Daniol Thomas

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

5K+ Views

To add a new enum column to an existing MySQL table, you can use ALTER command. Following is the syntax:ALTER TABLE yourTableName ADD yourColumnName ENUM('yourValue1', 'yourValue2’....N) NOT NULL;Let us first create a table:mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(200),    StudentAge ... Read More

Period negated() method in Java

Daniol Thomas

Daniol Thomas

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

45 Views

An immutable copy of a Period where all the Period elements are negated can be obtained using the method negated() in the Period class in Java. This method requires no parameters and it returns the Period elements after negating them.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; ... Read More

How to compare DateTime Column with only Date not time in MySQL?

Daniol Thomas

Daniol Thomas

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

1K+ Views

To compare DateTime column with only Date, you need to use the Date() method. Following is the syntax. Below, you need to date in the 'yourDateValue':select *from yourTableName where Date(yourColumnName)='yourDateValue';Let us first create a table:mysql> create table DemoTable (    ArrivalTime datetime ); Query OK, 0 rows affected (0.74 sec)Following ... Read More

MySQL query to delete a record with the lowest ID?

Daniol Thomas

Daniol Thomas

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

661 Views

To delete record with the lowest id, you can use the following syntax:delete from yourTableName order by yourColumnName limit 1;Let us first create a table:mysql> create table DemoTable (    Id int,    Name varchar(20) ); Query OK, 0 rows affected (0.75 sec)Following is the query to insert records in ... Read More

Write an example JDBC program demonstrating the batch processing with PreparedStatement object?

Daniol Thomas

Daniol Thomas

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

118 Views

Grouping related SQL statements into a batch and executing/submitting them at once is known as batch processing. The Statement interface provides methods to perform batch processing such as addBatch(), executeBatch(), clearBatch().Follow the steps given below to perform batch updates using the PreparedStatement object:Register the driver class using the registerDriver() method ... Read More

Alter row_format to dynamic in MySQL?

Daniol Thomas

Daniol Thomas

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

871 Views

To alter row_format to dynamic in MySQL, following is the syntax:ALTER TABLE yourTableName ROW_FORMAT=DYNAMIC;Let us first create a table:mysql> create table DemoTable (    CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    CustomerName varchar(200),    CustomerAge int,    CustomerAddress varchar(200) ); Query OK, 0 rows affected (0.73 sec)Let us check ... Read More

Write an example JDBC program demonstrating the batch processing with CallableStatement object?

Daniol Thomas

Daniol Thomas

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

626 Views

Grouping related SQL statements into a batch and executing/submitting them at once is known as batch processing. The Statement interface provides methods to perform batch processing such as addBatch(), executeBatch(), clearBatch().Follow the steps given below to perform batch updates using the CallableStatement object:Register the driver class using the registerDriver() method ... Read More

What is the syntax for input parameters (variables) in a MySQL query?

Daniol Thomas

Daniol Thomas

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

2K+ Views

To set a variable in MySQL, you need to use the SET command. Following is the syntax:set @yourVariableName:=yourValue; select *from yourTableName where yourColumnName=@yourVariableName;Let us first create a table:mysql> create table DemoTable (    Id int,    FirstName varchar(20),    LastName varchar(20) ); Query OK, 0 rows affected (0.83 sec)Following is ... Read More

How do I find out whether the underlying database supports batch processing?

Daniol Thomas

Daniol Thomas

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

200 Views

Not all the databases support batch processing therefore before proceeding with batch updates in your application. You need to verify whether the database you are trying to communicate supports batch processing/batch updates or not.You can do so using the supportsBatchUpdates() method of the DatabaseMetaData interface.Follow the steps given below:Register the ... Read More

How to process SQL statements with JDBC explain with an example?

Daniol Thomas

Daniol Thomas

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

5K+ Views

To process an SQL statement, you need to follow the steps given below:Establish the connection.Create a statement.Execute the statement/query.Process the result.Close the connection.Establishing a ConnectionTo process SQL statements first of all you need to establish connection with the desired DBMS or, file System or, other data sources.To do so, Register ... Read More

Advertisements