SQL Articles

Page 4 of 12

How to Get the names of the table in SQL

SQL
guru
guru
Updated on 01-Nov-2024 388 Views

In SQL databases, it is often necessary to retrieve the list of table names within a database to understand the structure or to perform the certain operations. Each SQL-based database system offers specific ways to query its metadata to extract the table names. In this article, we will explore how to get the names of tables in popular relational database systems including the MySQL, SQL Server, PostgreSQL and Oracle. We will cover the built-in SQL queries and functions that are commonly used for this task. Need to Retrieve Table Names? Database Exploration: When working with ...

Read More

SQL Query to Convert VARCHAR to INT

SQL
guru
guru
Updated on 25-Oct-2024 2K+ Views

In SQL, it is common to store data in different formats like VARCHAR, INT, FLOAT, etc. based on the needs of the application. However, sometimes we may need to convert a VARCHAR column to an INT for performing arithmetic operations, comparisons or other logical queries that require integer values. This article will explore various ways to convert VARCHAR (string) data types to INT in SQL using the built-in functions the potential pitfalls and examples. Why Convert VARCHAR to INT? While working with databases we may need to convert VARCHAR to INT in the following scenarios − ...

Read More

How To Reset Identity Column Values In SQL

SQL
Samriddhi Sharma
Samriddhi Sharma
Updated on 11-Oct-2024 181 Views

What is an Identity Column? The Identity column of a table is a column whose value increments consequently. This can be used to create unique identifiers, such as primary keys. Syntax Following is the syntax to create an Identity column. The initial setting for identity is represented as IDENTITY (1, 1). IDENTITY [ ( seed , increment ) ] Where − Seed: The seed determines the initial value of an ID, with a default setting of 1. Increment: This denotes the step value for ID increments, which also defaults ...

Read More

How to Set a Column Value to Null in SQL?

SQL
Samriddhi Sharma
Samriddhi Sharma
Updated on 11-Oct-2024 575 Views

Setting a Column Value to Null To set a column value to NULL, use the SQL UPDATE statement, which allows modification of existing records in a table. The basic syntax for setting a column value to NULL is − Syntax UPDATE table_name SET column_name = NULL WHERE conditions; Where − table_name: Replace this with the name of the table you intend to update. column_name: Substitute this with the name of the column to be updated. NULL: Denotes the NULL value in SQL. ...

Read More

Data Architecture Design & Data Management

Amrendra Patel
Amrendra Patel
Updated on 11-Oct-2024 3K+ Views

Data architecture design consists of standards that have certain rules, policies, and data types to be collected, from where the data is collected, storage of data, arrangement of data, and then using that data for further analysis. Data plays a vital role in the successful execution of business strategy. Data architecture design It helps us to show how users view the data in the database. It describes the type of data structures used to manage data and make the processing easy. the concept of dbms depends on its architecture. It is divided into three models i.e. conceptual model, ...

Read More

How to print duplicate rows in a table SQL

SQL
Akshada Bornare
Akshada Bornare
Updated on 25-Sep-2024 263 Views

Assume we have created a table in database and the table consists of duplicate records or, you need to check if there are multiple entries of the same record in the database. In order to find such duplicate records you can make use of below sample queries. Printing Duplicate Rows in an SQL Table Lets consider we have a table named as Students with the columns ID, Name, Age. Using the following query − CREATE TABLE Students( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE ...

Read More

How to Specify a Date Format on Creating a Table and Fill it in SQL?

SQL
Golden_Beach
Golden_Beach
Updated on 19-Sep-2024 954 Views

In SQL, date and time values are handled using specific data types, such as DATE, DATETIME, TIMESTAMP, etc. Each database management system (DBMS) may have its conventions for date formats, so understanding how to specify and use these formats is essential for working with dates in SQL. The following are the data types to handle date and time in SQL: DATE: Stores date values (year, month, day). DATETIME: Stores date and time values (year, month, day, hour, minute, second). TIMESTAMP: Stores date and time values, ...

Read More

SQL Query to Check if Date is Greater Than Today in SQL

SQL
Mithlesh Upadhyay
Mithlesh Upadhyay
Updated on 10-Sep-2024 785 Views

You can handle and manipulate date and time values within a database using SQL queries. You need to filter records based on date comparisons, like checking if a date is greater than today. We will query this using our own sample data as given below. Date Comparisons You can use various comparison operators, like >, =, and CURRENT_DATE; Here, date_column is the field containing the date values you want to compare. “CURRENT_DATE” is a keyword in SQL that represents the current date. Example Consider you have created a table named EVENTS using the CREATE TABLE statement as ...

Read More

How to Find Nth Highest Salary in SQL

SQL
bhavesh somani
bhavesh somani
Updated on 06-Aug-2024 6K+ Views

In this article, we will write an SQL(Structured Query Language) query to find the Nth highest salary from a database table. We can obtain the 2nd highest salary, 3rd highest salary, and so on. Certainly, This is the most commonly asked question in an interview. There are different methods to achieve this, we will understand every technique in detail. Problem Statement Assume we have a table named employees with 3 columns namely, EmployeeId, EmployeeName and, EmployeeSalary as shown below − EmployeeId EmployeeName EmployeeSalary 10001 Mahesh 33000 10002 John 35000 10003 Abdul 34500 ...

Read More

Production databases in SQL queries

sudhir sharma
sudhir sharma
Updated on 28-Jun-2024 526 Views

Overview Production databases are crucial for storing and retrieving data in organizations. SQL queries are essential for efficiently retrieving specific information from these databases. The article aims to equip readers with practical knowledge for working with production databases using SQL queries. Understanding SQL Queries and Relational Databases Relational databases provide a structured framework for organizing and storing data efficiently. Data modeling techniques, including normalization, help in designing effective databases. Understanding these concepts is essential for writing SQL queries that retrieve information accurately and efficiently from complex databases. Let’s dive into a few real world examples − Example 1 Creating ...

Read More
Showing 31–40 of 114 articles
« Prev 1 2 3 4 5 6 12 Next »
Advertisements