- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 6702 Articles for Database
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
141 Views
Following is the syntax to add column using alter in MySQL:alter table yourTableName add column yourColumnName yourDataType default yourValue;Let us first create a table:mysql> create table alterTableDemo -> ( -> Id int, -> Name varchar(10) -> ); Query OK, 0 rows affected (0.69 sec)Let us check the description of the table using DESC command. This displays Field, Type, Key, etc. of the table:mysql> desc alterTableDemo;This will produce the following output+-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | Id | int(11) | YES ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
201 Views
Yes, we can order with mathematical operations using ORDER BY clause. Let us first create a table:mysql> create table orderByMathCalculation -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Quantity int, -> Price int -> ); Query OK, 0 rows affected (0.57 sec)Following is the query to insert some records in the table using insert command:mysql> insert into orderByMathCalculation(Quantity, Price) values(10, 50); Query OK, 1 row affected (0.21 sec) mysql> insert into orderByMathCalculation(Quantity, Price) values(20, 40); Query OK, 1 row affected (0.14 sec) mysql> insert into orderByMathCalculation(Quantity, Price) values(2, 20); Query ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
The count(*) returns all rows whether column contains null value or not while count(columnName) returns the number of rows except null rows.Let us first create a table.Following is the querymysql> create table ifNotNullDemo -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.54 sec)Following is the query to insert some records in the table using insert command:mysql> insert into ifNotNullDemo values('Chris'); Query OK, 1 row affected (0.15 sec) mysql> insert into ifNotNullDemo values(''); Query OK, 1 row affected (0.13 sec) mysql> insert into ifNotNullDemo values('Robert'); Query OK, 1 row affected (0.24 sec) ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
8K+ Views
This type of error occurs if you select any database that does not exist in MySQL. Let us first display the error of unknown database in JDBC.The Java code is as follows. Here, we have set the database as ‘onlinebookstore’, which does not exist:import java.sql.Connection; import java.sql.DriverManager; public class UnknownDatabaseDemo { public static void main(String[] args) { String JdbcURL = "jdbc:mysql://localhost:3306/onlinebookstore?useSSL=false"; String Username = "root"; String password = "123456"; Connection con = null; try { con = DriverManager.getConnection(JdbcURL, Username, password); ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
284 Views
Let us first create a table. Following is the query −mysql> create table insertOneToAnotherTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.60 sec)Following is the query to insert some records in the table using insert command −mysql> insert into insertOneToAnotherTable values(100); Query OK, 1 row affected (0.08 sec) mysql> insert into insertOneToAnotherTable values(200); Query OK, 1 row affected (0.15 sec) mysql> insert into insertOneToAnotherTable values(300); Query OK, 1 row affected (0.13 sec) mysql> insert into insertOneToAnotherTable values(400); Query OK, 1 row affected (0.15 sec) mysql> insert into insertOneToAnotherTable ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
815 Views
To select results from the middle of a sorted list, use ORDER BY clause along with LIMIT.Let us first create a table. Following is the query −mysql> create table sortedListDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100) -> ); Query OK, 0 rows affected (0.46 sec)Following is the query to insert some records in the table using insert command −mysql> insert into sortedListDemo(StudentName) values('John'); Query OK, 1 row affected (0.62 sec) mysql> insert into sortedListDemo(StudentName) values('Sam'); Query OK, 1 row affected (0.18 sec) mysql> insert into sortedListDemo(StudentName) values('Adam'); ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
55 Views
To reorder integer except for value 0, use the below syntax −select *from yourTableName order by yourColumnName=0 ,yourColumnName;Let us first create a table −mysql> create table reorderIntegerExcept0 -> ( -> value int -> ); Query OK, 0 rows affected (0.70 sec)Following is the query to insert records in the table using insert command −mysql> insert into reorderIntegerExcept0 values(90); Query OK, 1 row affected (0.17 sec) mysql> insert into reorderIntegerExcept0 values(10); Query OK, 1 row affected (0.21 sec) mysql> insert into reorderIntegerExcept0 values(0); Query OK, 1 row affected (0.18 sec) mysql> insert into reorderIntegerExcept0 values(40); ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
4K+ Views
To insert current date to the database, you can use NOW(). Following is the syntax −INSERT INTO yourTableName(yourDateColumnName) VALUES(NOW());If your column has datatype date then NOW() function inserts only current date, not time and MySQL will give a warning. To remove the warning, you can use CURDATE().Let us first create a table −mysql> create table insertcurrentdate -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> currentDate date -> ); Query OK, 0 rows affected (1.09 sec)Following is the query to insert some records in the table using insert command. We have used both NOW() ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
588 Views
To format MySQL time with lowercase am/pm, use the LOWER() as well as DATE_FORMAT().Let us first create a table −mysql> create table formatTime -> ( -> LoginTime time -> ); Query OK, 0 rows affected (0.56 sec)Following is the query to insert records in the table using insert command −mysql> insert into formatTime values('12:40:34'); Query OK, 1 row affected (0.20 sec) mysql> insert into formatTime values('14:10:58'); Query OK, 1 row affected (0.13 sec) mysql> insert into formatTime values('16:56:40'); Query OK, 1 row affected (0.18 sec) mysql> insert into formatTime values('10:12:14'); Query OK, 1 row ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
306 Views
Use DATE_ADD() to add 10 minutes to datetime format. Following is the syntax −select date_add(yourColumnName ,interval 10 minute) from yourTableName;Let us first create a table −mysql> create table add10MinuteDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> DelayDatetime datetime -> ); Query OK, 0 rows affected (0.83 sec)Following is the query to insert records in the table using insert command −mysql> insert into add10MinuteDemo(DelayDatetime) values('2019-01-23 12:45:56'); Query OK, 1 row affected (0.16 sec) mysql> insert into add10MinuteDemo(DelayDatetime) values('2019-03-25 10:30:23'); Query OK, 1 row affected (0.19 sec) mysql> insert into add10MinuteDemo(DelayDatetime) values('2019-04-21 04:04:30'); Query ... Read More