Found 4589 Questions for MySQL

What are various Inheritance mapping strategies available in Hibernate?

Manu
Updated on 26-Aug-2022 11:47:53
There are three types of inheritance mapping strategies − Table per class hierarchy Table per concrete class Table per subclassIn this article, we will discuss table per class hierarchy. Table per class hierarchy In this, only a single table is created for inheritance mapping. Disadvantages of this approach is that a lot of null values gets stored in the table. @Inheritance(strategy=InheritanceType.SINGLE_TABLE), @DiscriminatorColumn and @DiscriminatorValue are the annotations used in this strategy. @DiscriminatorColumn is used to create an additional column which is used to identify the hierarchy classes. Consider the following example to understand this − Steps ... Read More

How to Execute Batch Insert Update in Hibernate?

Manu
Updated on 26-Aug-2022 11:40:06
In this article, we will see how we can execute batch insert/update in hibernate. Whenever we execute a sql statement, we do it by making a network call to the database. Now, if we have to insert 10 entries to our database table, then we have to make 10 network calls. Instead we can optimize our network calls by using batching. Batching allows us to execute a group of SQL statements in a single network call. To understand and implement this, let us define our entities − @Entity public class Parent { @Id @GeneratedValue(strategy ... Read More

How to connect hibernate with MySQL Database?

Manu
Updated on 26-Aug-2022 11:28:09
In this article, we will see how we can connect to MySQL database using an ORM (object relational mapping) framework like hibernate. First of all, we need to add maven dependency for hibernate in our pom.xml file − org.hibernate hibernate-core 5.6.2.Final Now, let us define an entity class that will be mapped to a database table using hibernate. @Entity @Table( name = " Employee") public class Employee { @Id @GeneratedValue(strategy = GenerationType.AUTO) Long id; @Column(name = ... Read More

Explain the difference between a table, view and synonym in SQL

Bhanu Priya
Updated on 03-Jul-2021 08:45:34
Let us understand what table, view and synonym in the structured query language (SQL) are.Table, view and synonymA table is a repository of data, where in the table it is a physical entity. A table resides physically in the database.A view is not a part of the database’s physical representation. It is precompiled, so that data retrieval behaves faster and also provides a secure accessibility mechanism.A synonym is an alternate name assigned to a table, view, sequence or program unit.ExampleCreate table employee (empID integer primary key, name varchar2(30), skill varchar2(30), salary number(20), DOB datetime).Let’s say there is a scenario where ... Read More

What is the use of update command in SQL?

Bhanu Priya
Updated on 03-Jul-2021 08:42:19
Update command is a data manipulation command which is used to edit the records of a table. It may be used to update a single row based on a condition, all rows or set of rows based on the condition given by the user.It is used along with the SET clause, operationally, a WHERE clause may be used to match conditions −Example 1An example is given below for the use of update command −update table student set name=’sneha’ where branch=’CSE’;Example 2Given below is another example of the usage of update command −create table employee(ename varchar(30), department varchar(20)); insert into employee ... Read More

How can you order the result obtained by select query in MySQL?

Pawandeep Kaur
Updated on 10-Jun-2021 12:26:46
It is common to select certain data or rows from a table. The rows are returned in the order in which they appear in the table. We may sometimes require that the rows we select from the table must be returned to us in ascending or descending order with respect to some column.The “ORDER BY” statement is used to order the results with respect to some column. The following example will provide more clarity.Suppose, we have a table which consists of various fields including the “name” field. We want to select all the rows from the table but we want ... Read More

Updating a record in MySQL using NodeJS

Mayank Agarwal
Updated on 28-Apr-2021 07:03:17
In this article, we will see how we can update a record in MySQL using NodeJS. We will dynamically update MySQL table values from Node.js server. You can use the select statement after updating to check if the MySql record is updated.Before proceeding, please check the following steps are already executed −mkdir mysql-testcd mysql-testnpm init -ynpm install mysqlThe above steps are for installing the Node - mysql dependecy in the project folder.Upadting a Record into the Students Table −For updating an existing record into the MySQL table, firstly create an app.js fileNow copy-paste the below snippet in the fileRun the ... Read More

Dropping a MySQL Table using NodeJS

Mayank Agarwal
Updated on 27-Apr-2021 09:34:02
You can delete an existing table from MySql Database using the "DROP TABLE" statement in Node. Sometimes, we need to delete the whole table, though in corporates it is always advised to archive the tables which are not in used instead of deleting them.While deleting a table, we have two scenarios −Deleting a table if it exists, else throw an errorDeleting the table whether it exists or not.We will discuss both the scenarios here.Before proceeding, please check the following steps are already executed −mkdir mysql-testcd mysql-testnpm init -ynpm install mysqlThe above steps are for installing the Node - mysql dependecy ... Read More

Deleting records in MySQL using Nodejs

Mayank Agarwal
Updated on 27-Apr-2021 09:21:34
After insertion, we need to delete records as well. The records should can be deleted based upon an identifier from the database table. You can delete records from table using "DELETE FROM" statement.We can delete the records from MySql DB in two ways −Static Deletion - In this type of deletion, we give a prefixed filter value to deleteDynamic Deletion – In this type of deletion, we ask for an input before deletion and then delete upon its basis.Before proceeding, please check the following steps are already executed −mkdir mysql-testcd mysql-testnpm init -ynpm install mysqlThe above steps are for installing ... Read More

Creating a MySQL table using Node.js

Mayank Agarwal
Updated on 27-Apr-2021 09:17:53
Generally, NoSQL databases (like MongoDB) are more popular among the Node developers. However, it totally depends upon your usecase and choice to choose any DBMS from different database options present. The type of databse you choose mainly depends upon one's project's requirements.For example, if you need table creation or real-time inserts and want to deal with loads of data, then a NoSQL database is the way to go, whereas if your project deals with more complex queries and transactions, an SQL database will make much more sense.In this article, we will explain how to connect to a MySQL and then ... Read More
1 2 3 4 5 6 7 ... 459 Next
Advertisements