Found 6705 Articles for Database

How to remove a record from an existing table in oracle database using JDBC API?

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

610 Views

You can remove a particular record from a table in a database using the DELETE query.SyntaxDELETE FROM table_name WHERE [condition];To delete a record from a table using JDBC API you need to −Register the Driver: Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection: Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Create Statement: Create a Statement object using the createStatement() method of the Connection interface.Execute the Query: Execute the query using the executeUpdate() method of the ... Read More

How to retrieve a record from an existing table in oracle database using JDBC API?

Arushi
Updated on 30-Jul-2019 22:30:26

1K+ Views

You can update/modify the existing contents of a record in a table using the UPDATE query. Using this you can update all the records of the table or specific records.SyntaxUPDATE table_name SET column1 = value1, column2 = value2...., columnN = valueN WHERE [condition];To update the contents of a record in a table using JDBC API you need to −Register the Driver: Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection: Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) ... Read More

Difference between Fundamental data types and derived Data Types

Kiran Kumar Panigrahi
Updated on 11-Jan-2023 15:01:51

3K+ Views

In computer programming, a datatype represents the type and nature of data that is to be used by the user. It is the data type that tells the compiler or interpreter how to deal with the data and provide corresponding storing location in computer memory. According to the nature of data, the data types can be of two types namely Fundamental Datatype and Derived Datatype. Both these datatypes are extensively used in computer programming. They are equally important when we require to implement the business logic over the data. Read this tutorial to find out more about Fundamental and Derived ... Read More

What is the equivalent of EXCEPT in MySQL?

Chandu yadav
Updated on 30-Jul-2019 22:30:26

4K+ Views

You cannot use EXCEPT in MySQL, instead use the NOT IN operator. Let us first create a table −mysql> create table DemoTable    (    Number1 int    ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(200); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(300); 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 −+---------+ | ... Read More

Which one is better POW() or POWER() in MySQL?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

185 Views

Both pow() and power() are synonyms in MySQL. Following is the syntax −select pow(yourValue1, yourValue2); OR select power(yourValue1, yourValue2);Let us implement both the above syntaxes.Using POW()mysql> select POW(4, 3);This will produce the following output −+----------+ | POW(4, 3) | +----------+ | 64 | +----------+ 1 row in set (0.00 sec)Using POWER()mysql> select POWER(4, 3);This will produce the following output −+------------+ | POWER(4, 3) | +------------+ | 64 | +------------+ 1 row in set (0.00 sec)Let us implement the above syntax in a table −mysql> create table ... Read More

How to get the primary key “column name” of a specific table in MySQL?

George John
Updated on 30-Jul-2019 22:30:26

949 Views

Let us first create a table wherein we have a Primary Key CustomerId −mysql> create table DemoTable    (    CustomerId int NOT NULL AUTO_INCREMENT,    CustomerName varchar(20),    CustomerAge int,    CustomerCountryName varchar(100),    PRIMARY KEY(CustomerId)    ); Query OK, 0 rows affected (0.94 sec)Following is the query to get the primary key “column name” of a specific table in MySQL −mysql> SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = 'DemoTable' AND CONSTRAINT_NAME = 'PRIMARY';This will produce the following output −+-------------+ | COLUMN_NAME | +-------------+ | CustomerId | +-------------+ 1 row in set, 2 warnings (0.12 sec)

Convert MM/DD/YY to Unix timestamp in MySQL?

Chandu yadav
Updated on 30-Jul-2019 22:30:26

411 Views

To convert MM/DD/YY to UNIX timestamp, you can use the below syntax −select UNIX_TIMESTAMP(str_to_date(yourColumnName, '%m/%d/%Y')) from yourTableName;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    dateConvertToUnix varchar(100)    ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(dateConvertToUnix) values('01/10/2001'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(dateConvertToUnix) values('03/31/2010'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(dateConvertToUnix) values('12/31/2016'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(dateConvertToUnix) values('04/27/2019'); Query OK, 1 ... Read More

How to apply Substring() for fields in MySQL to get part of string?

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

232 Views

You can use substring() for fields in MySQL to get part of string. Following is the syntax −select substring(yourColumnName, yourStartingIndex, yourEndingIndex) from yourTableName;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Title longtext    ); Query OK, 0 rows affected (0.57 sec)Insert records in the table using insert command −mysql> insert into DemoTable(Title) values('MySQL is a relational database management system'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Title) values('MongoDB is a popular No SQL database'); Query OK, 1 row affected (0.18 sec)Display all records from ... Read More

Problem using the column name 'from' in a MySQL query?

George John
Updated on 30-Jul-2019 22:30:26

355 Views

You cannot use ‘from’ as column name directly because ‘from’ is a reserved word in MySQL.If you want to still use it, then you need to use the backtick symbol.Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    `from` varchar(100),    Name varchar(10)    ); Query OK, 0 rows affected (0.92 sec)Insert records in the table using insert command −mysql> insert into DemoTable(`from`, Name) values('US', 'John'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(`from`, Name) values('UK', 'Carol'); Query OK, 1 row affected (0.14 sec) mysql> ... Read More

How to concatenate all columns in MySQL?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

2K+ Views

First, you need to know how many columns are present in a table. Following is the syntax to know the column names −show columns from yourTableName;Following is the syntax to concatenate all columns −select concat(yourColumnName1, yourColumnName2, yourColumnName3, ........N) from yourTableName;Let us first create a table −mysql> create table DemoTable    (    CustomerId int,    CustomerName varchar(20),    CustomerAge int    ); Query OK, 0 rows affected (0.66 sec)Following is the query to know the exact column −mysql> show columns from DemoTable;This will produce the following output −+--------------+-------------+------+-----+---------+-------+ | Field        | Type        | Null ... Read More

Advertisements