0% found this document useful (0 votes)
8 views

Rdbms Slide 2

Uploaded by

Abdul Aziz
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Rdbms Slide 2

Uploaded by

Abdul Aziz
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

e m

y st
S
n t
e
e m
ag
an
M
se
ba
a
S D at
M
B nal
RD tio a
el
R

Slide-2
Field and Record
Field: A field is a single piece of information or attribute in a database. It
represents a column in a table and holds data of a specific type
(e.g., name, age, address). Each field has a field name (or column name)
that describes the type of data it contains. For example, in a table storing
employee information, fields might include "First Name," "Last Name,"
"Date of Birth," and "Employee ID.“

Record: A record is a complete set of related fields that represent a single


entry in a table. It corresponds to a row in a table. Each record
contains a unique value or a combination of values across its fields to
represent a specific entity. For example, in the same employee information
table, a record would contain the first name, last name, date of birth, and
employee ID of one employee.
Field and Record
Example:

Fields: "Employee ID," "First Name," "Last Name," and "Date of Birth" are fields
Record: Each row (e.g., 101, John, Doe, 1990-01-01) is a record.

In summary, a field is a single piece of information (a column


while a record is a collection of related fields (a row)
Adding A
Column
ER TABLE table_name ADD New_Column_name data_type

TABLE table_name ADD New_Column_name data_type(L) AFTER selected_co

FIRST
Removing A Column

LTER TABLE table_name DROP column_name

DROP TABLE table_name;

ALTER TABLE Customers


DROP COLUMN ContactName;
Modifying A Column

ALTER TABLE table_name MODIFY column_name data_type(L);

ALTER TABLE table_name ALTER COLUMN column_name datatype(L);

ALTER TABLE table_name RENAME COLUMN old_name to new_name;

SQL Server / MS Access:


My SQL / Oracle
PRIMARY KEY
The PRIMARY KEY constraint uniquely identifies each record in a
table.
Primary keys must contain UNIQUE values, and cannot contain NULL
values.
A table can have only ONE primary key; and in the table, this
primary key can consist of single or multiple
CREATE columns
TABLE (fields).
Persons (
CREATE TABLE Persons (
ID int NOT NULL PRIMARY KEY, ID int NOT NULL,
LastName varchar(255) NOT NULL, LastName varchar(255) NOT NULL,
FirstName varchar(255), FirstName varchar(255),
Age int Age int,
); PRIMARY KEY (ID)
);
PRIMARY KEY
To allow naming of a PRIMARY KEY constraint, and for defining a PRIMARY
KEY constraint on multiple columns, use the following SQL syntax:

CREATE TABLE Persons (


ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
CONSTRAINT PK_Person PRIMARY KEY (ID,LastName)
);

Note: In the example above there is only ONE PRIMARY KEY (PK_Person). However,
the VALUE of the primary key is made up of TWO COLUMNS (ID + LastName).
PRIMARY KEY
To create a PRIMARY KEY constraint on the "ID" column when
the table is already created, use the following SQL:

ALTER TABLE Persons


ADD PRIMARY KEY (ID);

To allow naming of a PRIMARY KEY constraint, and for defining


a PRIMARY KEY constraint on multiple columns, use the following
SQL syntax:
ALTER TABLE Persons
ADD CONSTRAINT PK_Person PRIMARY KEY (ID,LastName);

SQL PRIMARY KEY on ALTER TABLE


PRIMARY KEY
To drop a PRIMARY KEY constraint, use the following SQL:

ALTER TABLE Persons


DROP PRIMARY KEY;

DROP a PRIMARY KEY Constraint


Delete Truncate

DELETE FROM table name; TRUNCATE table name;

DELETE FROM table_name WHE


RE
condition;
DELETE FROM employees
WHERE Emp_id = 12;

You might also like