0% found this document useful (0 votes)
29 views7 pages

Varchar

The document compares and contrasts the VARCHAR and VARCHAR2 data types in Oracle databases. VARCHAR allows for variable length character strings up to 2000 bytes while VARCHAR2 allows up to 4000 bytes. VARCHAR data is padded to the right with spaces if it is shorter than the defined length, while VARCHAR2 truncates extra spaces. VARCHAR2 is Oracle's standard implementation while VARCHAR is from an external standard.

Uploaded by

Piyush jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views7 pages

Varchar

The document compares and contrasts the VARCHAR and VARCHAR2 data types in Oracle databases. VARCHAR allows for variable length character strings up to 2000 bytes while VARCHAR2 allows up to 4000 bytes. VARCHAR data is padded to the right with spaces if it is shorter than the defined length, while VARCHAR2 truncates extra spaces. VARCHAR2 is Oracle's standard implementation while VARCHAR is from an external standard.

Uploaded by

Piyush jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Varchar Varchar2

Varchar may hold character data Varchar2 can store character data
in increments of 1 to 2000 bytes. in increments of 1 to 4000 bytes.

No matter the input, allocate data Distribute data of varying sizes


of a fixed size. based on input.

Extra spaces are padded to the Extra spaces in varchar2 will be


right side for varchar data. truncated.

The ANSI SQL standard uses Oracle uses the Varchar2


Varchar. standard.
Varchar's definition might alter in The definition of Varchar2 won't
the future. change. It is customary.

Varchar is a third-party datatype. Varchar2 is a data type that is


internal.
SQL MySQL

SQL is a standard language


which stands for Structured MySQL is a database
Query Language based on the management system.
English language
SQL is the core of the relational MySQL is an RDMS (Relational
database which is used for Database Management System)
accessing and managing such as SQL Server, Informix
database etc.

What are the different subsets of SQL?


 Data Definition Language (DDL) – It allows you to perform
various operations on the database such as CREATE,
ALTER, and DELETE objects.
 Data Manipulation Language(DML) – It allows you to
access and manipulate data. It helps you to insert, update,
delete and retrieve data from the database.
 Data Control Language(DCL) – It allows you to control
access to the database. Example – Grant, Revoke access
permissions.

What are some common clauses used with SELECT query


in SQL?
The following are some frequent SQL clauses used in conjunction with a
SELECT query:

WHERE clause: In SQL, the WHERE clause is used to filter records that
are required depending on certain criteria.
ORDER BY clause: The ORDER BY clause in SQL is used to sort data
in ascending (ASC) or descending (DESC) order depending on specified
field(s) (DESC).
GROUP BY clause: GROUP BY clause in SQL is used to group entries
with identical data and may be used with aggregation methods to obtain
summarised database results.
HAVING clause in SQL is used to filter records in combination with the
GROUP BY clause. It is different from WHERE, since the WHERE
clause cannot filter aggregated records.
There are different types of relations in the database:

One-to-One – This is a connection between two tables in which each


record in one table corresponds to the maximum of one record in the
other.

One-to-Many and Many-to-One – This is the most frequent connection,


in which a record in one table is linked to several records in another.

Many-to-Many – This is used when defining a relationship that requires


several instances on each sides.

What are Tables and Fields?

A table is a collection of data components organized in rows


and columns in a relational database. A table can also be
thought of as a useful representation of relationships. The most
basic form of data storage is the table. An example of an
Employee table is shown below.

ID Name Department Salary


1 Rahul Sales 24000
2 Rohini Marketing 34000
3 Shylesh Sales 24000
4 Tarun Analytics 30000

A Record or Row is a single entry in a table. In a table, a record


represents a collection of connected data. The Employee table,
for example, has four records.

A table is made up of numerous records (rows), each of which


can be split down into smaller units called Fields(columns). ID,
Name, Department, and Salary are the four fields in the
Employee table above.
What is a UNIQUE constraint?
The UNIQUE Constraint prevents identical values in a column
from appearing in two records. The UNIQUE constraint
guarantees that every value in a column is unique.

What is the difference between NOW() and


CURRENT_DATE()?
NOW() returns a constant time that indicates the time at which
the statement began to execute. (Within a stored function or
trigger, NOW() returns the time at which the function or
triggering statement began to execute.
The simple difference between NOW() and CURRENT_DATE()
is that NOW() will fetch the current date and time both in format
‘YYYY-MM_DD HH:MM:SS’ while CURRENT_DATE() will fetch
the date of the current day ‘YYYY-MM_DD’.
How to remove duplicate rows in SQL?
If the SQL table has duplicate rows, the duplicate rows must be
removed.
Let’s assume the following table as our dataset:

ID Name Age
1 A 21
2 B 23
2 B 23
4 D 22
5 E 25
6 G 26
5 E 25
The following SQL query removes the duplicate ids from the table:

DELETE FROM table WHERE ID IN (


SELECT ID, COUNT(ID) FROM table GROUP BY ID HAVING
COUNT (ID) > 1);

You might also like