Bharti Kumari

Bharti Kumari

21 Articles Published

Articles by Bharti Kumari

Page 2 of 3

SQL Query to Demonstrate Deletion Anomaly in Referential Integrity in a Table

Bharti Kumari
Bharti Kumari
Updated on 27-Jan-2023 546 Views

Introduction A SQL query is a request for data from a database. In the context of demonstrating a deletion anomaly in a table with referential integrity, a SQL query would be used to delete a record from the parent table and observe the impact on the related records in the child table. To demonstrate a deletion anomaly, we can create two tables with a foreign key constraint, insert some sample data, and then use a `DELETE` statement to delete a record from the parent table. We can then use a `SELECT` statement to retrieve the data from the child table ...

Read More

SQL Query to Demonstrate Addition Anomaly in Referential Integrity in a Table

Bharti Kumari
Bharti Kumari
Updated on 27-Jan-2023 266 Views

Introduction To demonstrate an addition anomaly in a referential integrity in a table, we can create a simple database with two tables: a parent table and a child table. The parent table should have a primary key column, and the child table should have a foreign key column that references the primary key column in the parent table. We can then insert some rows into both tables and run a SELECT statement on the child table that filters the results based on a column from the parent table. If we delete a row from the parent table, the result of ...

Read More

Set Database From Single User Mode to Multi User in SQL?

Bharti Kumari
Bharti Kumari
Updated on 25-Jan-2023 19K+ Views

Introduction In SQL, a database can be set to single user mode or multi user mode. When a database is in single user mode, only one user can connect to the database at a time. This can be useful for maintenance tasks that need to be performed on the database, as it ensures that no other users are modifying the data while the maintenance is being done. However, once the maintenance is complete, it is usually necessary to set the database back to multi user mode so that multiple users can connect to the database and access the data. This ...

Read More

Oracle DataBase – Grant Privileges to a User in SQL Command Line

Bharti Kumari
Bharti Kumari
Updated on 25-Jan-2023 12K+ Views

Introduction In an Oracle Database, privileges are used to control access to the database's objects and operations. A privilege is a permission to perform a specific action on a specific object, such as SELECTing data from a table or EXECUTing a stored procedure. When you create a user in the database, that user does not have any privileges by default. In order for the user to be able to perform any actions, you must grant them the necessary privileges. This can be done by using the GRANT command in SQL command line. When a user has been granted a privilege, ...

Read More

How to Setup Compatibility in Microsoft SQL Server?

Bharti Kumari
Bharti Kumari
Updated on 25-Jan-2023 693 Views

Introduction The compatibility level of a database is important because it determines which features are available and can also affect the performance of queries and other operations in the database. For example, if a database has a compatibility level of 100 (SQL Server 2008), certain features that were introduced in later versions of SQL Server, such as memory-optimized tables or table variables with large record sizes, will not be available for use in that database. It is important to set the compatibility level of a database to the correct level, as changing the compatibility level of a database can cause ...

Read More

How to Rename SQL Server Schema?

Bharti Kumari
Bharti Kumari
Updated on 25-Jan-2023 7K+ Views

Introduction To rename a schema in SQL Server, you can use the sp_rename stored procedure to change the name of the schema. Before you can rename a schema, you need to make sure that the schema is not being used by any objects in the database. You can do this by running a query to check for objects that belong to the schema. If the schema is being used by objects in the database, you will need to either drop or transfer ownership of the objects to a different schema before you can rename the schema. Once you have ...

Read More

How to Convert MySQL Table Field Type from BLOB to JSON?

Bharti Kumari
Bharti Kumari
Updated on 25-Jan-2023 5K+ Views

Introduction If you have a table in MySQL with a BLOB field that you would like to convert to a JSON field, it can be done by performing a series of ALTER TABLE statements. The process involves creating a new column with the desired data type (JSON), copying the data from the old column to the new column, dropping the old column, and renaming the new column to the original column name. It's important to note that BLOB fields are used to store binary data, and JSON is a text-based format for representing data. In order to convert a BLOB ...

Read More

How to Change DB Schema to DBO in SQL?

Bharti Kumari
Bharti Kumari
Updated on 25-Jan-2023 3K+ Views

Introduction In SQL Server, a schema is a container for database objects such as tables, views, and stored procedures. The `dbo` schema is the default schema for the database owner (also known as the "database principal"). There may be times when you want to change the schema of a database object in SQL Server. For example, you might want to move a table from one schema to another to better organize your database, or you might want to change the schema of an object to match the schema of other objects in your database. To change the schema of a ...

Read More

Displaying the Employees in Increasing Order of their Salaries in SQL Server

Bharti Kumari
Bharti Kumari
Updated on 25-Jan-2023 2K+ Views

Introduction Displaying employees in increasing order of their salaries in SQL Server involves a few steps. First, you need to have a database and a table that stores information about employees, including their salaries. Once you have that, you can use SQL commands to query the table and retrieve the data in the desired order. To retrieve the data in increasing order of salary, you can use the ORDER BY clause in a SELECT statement. The ORDER BY clause is used to sort the results of a query by one or more columns. In this case, you would use it ...

Read More

Displaying Department Name Having Most Number of Employees in SQL Server

Bharti Kumari
Bharti Kumari
Updated on 25-Jan-2023 4K+ Views

Introduction Displaying the department with the most number of employees in SQL Server is a common task that can be accomplished using a SQL query. The query will typically involve joining the employees and departments tables on the department ID, grouping the results by department name, and counting the number of employees in each department. Then use aggregate functions like COUNT() and TOP 1 with ORDER BY clause to get the desired result. To display the department name that has the most number of employees in SQL Server, it requires to have two database tables - Employees and Departments with ...

Read More
Showing 11–20 of 21 articles
Advertisements