0% found this document useful (0 votes)
11 views6 pages

sql Command and constant

SQL, or Structured Query Language, is the standard language for managing relational databases, enabling users to store, manipulate, and retrieve data. Key SQL commands include CREATE, SELECT, INSERT, UPDATE, DELETE, and DROP, which are categorized into DDL, DML, and DCL. Additionally, constraints such as NOT NULL, UNIQUE, PRIMARY KEY, and FOREIGN KEY ensure data integrity and reliability within the database.

Uploaded by

Rasel
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)
11 views6 pages

sql Command and constant

SQL, or Structured Query Language, is the standard language for managing relational databases, enabling users to store, manipulate, and retrieve data. Key SQL commands include CREATE, SELECT, INSERT, UPDATE, DELETE, and DROP, which are categorized into DDL, DML, and DCL. Additionally, constraints such as NOT NULL, UNIQUE, PRIMARY KEY, and FOREIGN KEY ensure data integrity and reliability within the database.

Uploaded by

Rasel
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/ 6

What is SQL

 SQL is Structured Query Language, which is a computer language for storing, manipulating and
retrieving data stored in a relational database.

 SQL is the standard language for Relational Database System. All the Relational Database
Management Systems (RDMS) like MySQL, MS Access, Oracle, Sybase, Informix, Postgres and SQL
Server use SQL as their standard database language.

SQL Commands

• The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT,
UPDATE, DELETE and DROP. These commands can be classified into the following groups based on
their nature:

DDL - Data Definition Language

DML - Data Manipulation Language

[email protected] 1
DCL - Data Control Language

Connecting to SQL Server using SSMS

SQL Server Management Studio (SSMS), is the client tool that can be used to write and execute SQL
queries.
To connect to the SQL Server Management Studio
1. Click Start
2. Select All Programs
3. Select Microsoft SQL Server 2005, 2008, or 2008 R2 (Depending on the version installed)
4. Select SQL Server Management Studio

Connect to Server window.


1. Select Database Engine as the Server Type. The other options that you will see here are Analysis
Services(SSAS), Reporting Services (SSRS) and Integration Services(SSIS). Server type = Database
Engine

2. Next you need to specify the Server Name. Here we can specify the name or the server or IP
Address . If you have SQL Server installed on your local machine, you can specify, (local) or just .
(Period) or 127.0.0.1 Server name = (local)

3. Now select Authentication. The options available here, depends on how you have installed SQL
Server. During installation, if you have chosen mixed mode authentication, you will have both
Windows Authentication and SQL Server Authentication. Otherwise, you will just be able to connect
using windows authentication.

4. If you have chosen Windows Authentication, you dont have to enter user name and password,
otherwise enter the user name and password and click connect.

[email protected] 2
Developer Machines 1,2,3 and 4 connects to the database server using SSMS.

Consistency constraints
The database system checks these constraints every time the database is updated. In general, a constraint can
be an arbitrary predicate pertaining to the database. The data values stored in the database must satisfy certain
Thus, database systems implement integrity constraints that can be tested with minimal overhead:

Domain Constraints. A domain of possible values must be associated with every attribute (for example,
integer types, character types, date/time types).

Referential Integrity. There are cases where we wish to ensure that a value that appears in one relation for a
given set of attributes also appears in a certain set of attributes in another relation (referential integrity).

Assertions . An assertion is any condition that the database must always satisfy. Domain constraints and
referential-integrity constraints are special forms of assertions. For example, “Every department must have at
least five courses offered every semester” must be expressed as an assertion.

Authorization. We may want to differentiate among the users as far as the type of access they are permitted
on various data values in the database.

SQL ─ Constraints

• Constraints are the rules enforced on the data columns of a table.


• These are used to limit the type of data that can go into a table.
• This ensures the accuracy and reliability of the data in the database.
• Constraints could be either on a column level or a table level.
• The column level constraints are applied only to one column, whereas the table level constraints are
applied to the whole table.
Constraints
• NOT NULL Constraint: Ensures that a column cannot have a NULL value.
• DEFAULT Constraint: Provides a default value for a column when none is specified.
• UNIQUE Constraint: Ensures that all values in a column are different.
• PRIMARY Key: Uniquely identifies each row/record in a database table.
• FOREIGN Key: Uniquely identifies row/record in any of the given database tables.

[email protected] 3
• CHECK Constraint: The CHECK constraint ensures that all the values in a column satisfies certain
conditions.
• INDEX: Used to create and retrieve data from the database very quickly.

SQL - NOT NULL Constraint


• By default, a column can hold NULL values. If you do not want a column to have a NULL value, then
you need to define such a constraint on this column specifying that NULL is now not allowed for that
column.

DEFAULT Constraint

• The DEFAULT constraint provides a default value to a column when the INSERT INTO statement
does not provide a specific value.

UNIQUE Constraint

• The UNIQUE Constraint prevents two records from having identical values in a column. In the
CUSTOMERS table, for example, you might want to prevent two or more people from having an
identical age.

[email protected] 4
Primary Key

• A primary key is a field in a table which uniquely identifies each row/record in a database table.
Primary keys must contain unique values. A primary key column cannot have NULL values.
• A table can have only one primary key, which may consist of single or multiple fields.When multiple
fields are used as a primary key, they are called a composite key.

Foreign Key

• A foreign key is a key used to link two tables together. This is sometimes also called as a referencing
key.
• A Foreign Key is a column or a combination of columns whose values match a Primary Key in a
different table.

CHECK Constraint

• The CHECK Constraint enables a condition to check the value being entered into a record.

• If the condition evaluates to false, the record violates the constraint and isn't entered the table.

[email protected] 5
INDEX Constraint

• The INDEX is used to create and retrieve data from the database very quickly.

• An Index can be created by using a single or a group of columns in a table. When the index is created,
it is assigned a ROWID for each row before it sorts out the data.

[email protected] 6

You might also like