
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6705 Articles for Database

148 Views
Use SELECT ENGINE to display the storage engine name. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Age int, -> CountryName varchar(20) -> ); Query OK, 0 rows affected (0.63 sec)Here is the Java code to get the storage engine using JDBC −Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class GetTheStorageEngine { public static void main(String[] args) { String hostURL = "jdbc:mysql://localhost:3306/web?useSSL=false"; Connection con = null; ... Read More

335 Views
To get the last second of a date in MySQL, use the INTERVAL command. Let us first create a table −mysql> create table DemoTable -> ( -> JoiningDatetime datetime, -> DueDatetime datetime -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(JoiningDatetime) values('2019-11-03 12:34:54'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(JoiningDatetime) values('2019-10-04 12:34:54'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------------------+-------------+ | JoiningDatetime ... Read More

181 Views
You can use ORDER BY TRIM(). Let us first create a table −mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (1.09 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('MongoDB is a no SQL database'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('The MySQL is a relational database'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('The Java language is good'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values('Python is good language'); Query ... Read More

414 Views
To fix, you need to put MySQL connector to the Java classpath. Import the jar file of the connector to the project folder for the IDE you are using.Here is the snapshot to place classpath −Let us now see the code for connectivity in Java with MySQL −This will produce the following output −

384 Views
To replace only a single character, use REPLACE() in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John Smitk'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('David Miller'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Adam Smitk'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following ... Read More

109 Views
For this, you can use ORDER BY IFNULL(). Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20), -> CountryName varchar(20) -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', NULL); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('David', 'AUS'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(NULL, 'UK'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(NULL, 'AUS'); Query OK, 1 row affected (0.10 sec) mysql> ... Read More

1K+ Views
For this, you can use the UPDATE command along with the WHERE clause in a PROCEDURE. Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(101, 'David', 'Brown'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(102, 'Chris', 'Brown'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(103, 'John', 'Doe'); Query OK, 1 row affected (0.07 ... Read More

277 Views
If we will insert nothing in the INSERT statement, then for timestamp type, it would insert the current date-time. Let us first create a table −mysql> create table DemoTable -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserLoginDate timestamp default current_timestamp -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.08 ... Read More

157 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Value varchar(20) -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('20'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('10.5'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('11'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('10'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('20.5'); Query OK, 1 row affected (0.13 sec)Display all records from the table ... Read More

238 Views
Use the STR_TO_DATE() method to insert date records as in the below syntax −select str_to_date(yourColumnName, '%b %Y') from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> JoiningYear varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Jan 2018'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('May 2107'); Query OK, 1 row affected (0.32 sec) mysql> insert into DemoTable values('Aug 2019'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Oct 2020'); Query OK, ... Read More