SQL Articles

Page 6 of 12

SQL Query to Convert Rows to Columns in SQL Server

Bharti Kumari
Bharti Kumari
Updated on 22-Oct-2023 32K+ 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

How to Update Two Tables in One Statement in SQL Server?

Bharti Kumari
Bharti Kumari
Updated on 14-Sep-2023 53K+ 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 Convert Epoch Time to Date in SQL?

Bharti Kumari
Bharti Kumari
Updated on 02-Sep-2023 73K+ 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

Data anomalies in DBMS

Amrendra Patel
Amrendra Patel
Updated on 22-Aug-2023 19K+ Views

Anomalies means problems or inconsistency which happened during the operations performed on the table. There can be many reasons that anomaly occur for example, It occurs when data is stored multiple times unnecessarily in the database i.e. redundant data is present or it occur when all the data is stored in a single table. normalization is used to overcome the anomalies. the different type of anomalies are insertion, deletion and updation anomaly. Input The same input is used for all three anomalies. Student ID Name Age Branch Branch_Code Hod_name 1 A 17 Civil 101 Aman ...

Read More

Current user function in SQL

Amrendra Patel
Amrendra Patel
Updated on 22-Aug-2023 685 Views

It is used to return the name of the current user in sql database server. it does not accept any parameter. Syntax CURRENT_USER Current_user is the function used to get the name of current user Example 1 In this example, we are going to use the current_user function to get the current user name. Input Employee Emp_id Name Dept_name Salary 1 Monu IT 50000 2 Sonu HR 60000 3 Golu Security 70000 This database is currently used by amrendra. Code SELECT CURRENT_USER;#selected current user name Output Amrendra ...

Read More

Creating materialised view using table definition in cassandra

Amrendra Patel
Amrendra Patel
Updated on 22-Aug-2023 193 Views

A materialised is defined as a database object that contains the results of a particular query. It could be called as a subset of a table. Any changes in the base table would be reflected in the materialised view. Syntax CREATE MATERIALISED VIEW view_name AS SELECT * FROM table_name WHERE column_name IS NOT NULL PRIMARY KEY (provide_primary_key) Here, view_name is the name of the materialised view, table_name is the base table, column_name are the columns provide_primary_key are the primary keys for the base table. Example 1 In this example, we are gonna have a ...

Read More

Create, Alter & Drop schema

Amrendra Patel
Amrendra Patel
Updated on 22-Aug-2023 274 Views

Create a schema Schema is basically the logical representation of the database. there is a default schema named dbo. Objects gets created inside a schema when ‘create schema’ statement is used. To provide access to other user after the schema is created, we need to impersoinate permissions. Syntax:The syntax to create a schema is − Create schema schema_name Here, we have created a schema named schema_name. Example 1: Granting permissions In this example, we are going to create a schema and grant permissions to have access to that. Algorithm Step 1 − Create a schema. Step 2 − ...

Read More

Create login in SQL Server

Amrendra Patel
Amrendra Patel
Updated on 22-Aug-2023 476 Views

A login is a security check process to authenticate the user and make their data secure. In case of SQL, we need to login to connect to the server. Creating login for the server gives a security advantage. Also, security implications are to be understood and kept in mind while creating a login. A user will be granted the access of the database after user login is provided. Here, we are going to use various methods. Method 1: login with Password We are going to use simply the userid and password to login to the server. Syntax Create login ...

Read More

How to Get Value from SQLAlchemy Instance by Column Name?

Way2Class
Way2Class
Updated on 27-Jul-2023 3K+ Views

SQLAlchemy is a SQL toolkit and Object-Relational Mapping (ORM) system for the Python programming language. It offers a full suite of well-known enterprise-level persistence patterns, intended for data manipulation in SQL. One feature developers often seek to utilize is accessing the value from a SQLAlchemy instance using a column name. This powerful technique can streamline database operations and improve code readability. This article guides you through the process of using this feature in your Python program, showcasing two practical approaches. Syntax Before we delve into the procedures, let's establish the syntax of the method we will use in our following ...

Read More

DML(Data Manipulation Language)

Amrendra Patel
Amrendra Patel
Updated on 14-Jul-2023 2K+ Views

It refers to a language that is used to insert, delete and update data in a database. It is used for the manipulation of data in the database.DCL is used together with DML because the changes made by dml wouldn't be saved permanently and have a chance of rolling back. Here are three DML commands: Insert into command It is used to insert a data row in a table. Syntax INSERT INTO table_name(col1, col2, col3, ..) VALUES (value1, value2, value3, ...); or INSERT INTO table_name VALUES (value1, value2, value3, ...); Example This example will show the ...

Read More
Showing 51–60 of 115 articles
« Prev 1 4 5 6 7 8 12 Next »
Advertisements