Found 6702 Articles for Database

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

Bharti Kumari
Updated on 27-Jan-2023 10:07:04

130 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

SQL Query to Convert Rows to Columns in SQL Server

Bharti Kumari
Updated on 22-Oct-2023 02:36:05

28K+ Views

Introduction The PIVOT operator is used to rotate rows of a table into columns. It is useful for generating cross-tabular reports, where the results are presented in a summary form. The PIVOT operator is available in SQL Server 2005 and later versions. The PIVOT operator is used to convert rows into columns in a SQL Server database. It is often used to generate cross-tabular reports, where the results are presented in a summary form. Definition In SQL Server, the PIVOT operator allows you to convert rows into columns. It is useful for generating cross-tabular reports, where the results are ... Read More

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

Bharti Kumari
Updated on 25-Jan-2023 11:23:30

16K+ 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
Updated on 25-Jan-2023 11:20:37

9K+ 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 Update Two Tables in One Statement in SQL Server?

Bharti Kumari
Updated on 14-Sep-2023 15:59:24

40K+ Views

Introduction In SQL Server, you may sometimes need to update data in multiple tables at the same time. This can be done using a single UPDATE statement, which allows you to update multiple tables in a single query. To update two tables in one statement, you can use the UPDATE statement with a JOIN clause. The JOIN clause allows you to specify a relationship between the two tables that you want to update, based on a common column or set of columns. Definition The term "update two tables in one statement" refers to the process of using a single UPDATE ... Read More

How to Setup Compatibility in Microsoft SQL Server?

Bharti Kumari
Updated on 25-Jan-2023 11:13:04

416 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
Updated on 25-Jan-2023 11:11:18

6K+ 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 List All Tables in a Schema in Oracle Database?

Bharti Kumari
Updated on 04-Oct-2023 13:11:29

39K+ Views

Introduction In Oracle databases, a schema is a logical grouping of related objects, such as tables, views, and stored procedures. Each schema belongs to a specific database user and has a set of associated privileges. To list all tables in a schema in an Oracle database, you can use one of the views in the data dictionary. The `ALL_TABLES` view contains one row for each table in the current schema, while the `DBA_TABLES` view contains one row for each table in the entire database. To list the tables in a schema, you can use a SELECT statement to query the ... Read More

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

Bharti Kumari
Updated on 25-Jan-2023 11:08:40

3K+ 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 Convert Epoch Time to Date in SQL?

Bharti Kumari
Updated on 02-Sep-2023 16:04:28

58K+ Views

Introduction The epoch is the date and time relative to which a computer's clock and timestamp values are determined. Epoch time is commonly used in computer systems to represent a point in time. It is typically represented as a single integer value, which represents the number of seconds that have elapsed since the epoch. In SQL, you can convert an epoch time value to a date by using the to_timestamp() function. This function converts an epoch time value (which is typically stored as a BIGINT or INT data type) to a timestamp with time zone value. The resulting timestamp value ... Read More

Advertisements