Join date: Apr 12, 2022


SQL Table and SQL Constraints

SQL Tables -

In Relational Database system (RDBMS) the data is stored in database objects called tables. Table is basically a collection of related data and it consists of numerous rows and columns. According to table is the simplest and the most common form of data storage.

• Create Table – It is used to create Table in the database.

The data_type can be anything number (int, float), text (char, varchar), date, etc.

Here ‘NOT NULL’, ‘UNIQUE’ are SQL Constraints.

• Drop Table – It is used to delete table and all the data from the table.

The deleted information is lost forever.

DROP TABLE "table_name";

For Example – DROP TABLE Studen_info;

• Alter Table – It is used to modify the table by adding or deleting column, change constraints, etc.

According to homework answers service adding column to the table -

ALTER TABLE table_name ADD column_name data_type(size);

For Example - ALTER TABLE Student_info ADD Contact_no varchar(30);

Drop column to the table -

ALTER TABLE table_name DROP column_name;

For Example - ALTER TABLE Student_info DROP Contact_no;


SQL Constraints :

SQL Constraints are the rules enforced on the data columns. They are used to limit the type of data in the database. There are various constraints such as – • NOT NULL – This constraint ensures that the column cannot have any Null Value. • DEFAULT – It provides a default value to the column when any value is not specified. • UNIQUE – It ensures that all the values of the column are Unique. • PRIMARY KEY – It uniquely identifies each row in the table. • FOREIGN KEY - It uniquely identifies row in the other table. • CHECK - It ensures that the values in the column satisfy certain condition. • E – Cancels the privileges granted to the user.

Data Definition Language (DDL) –

DDL is used to define the database schema. These Commands are used to manipulate database structures and not data of the database.

DDL commands are –

• CREATE – It creates objects of database such as table, view.

• ALTER – It modifies existing database objects such as table, etc

• DROP – Deletes objects from the database.

Data Manipulation Language (DML) –

DML is used to perform operations on the data in the database. These Commands are used to insert, delete, update data from the database.

DML commands are –

• INSERT – It is used to create record i.e insert data into database.

• SELECT – It is used to read data from the database.

• UPDATE – It modifies data in the database.

• DELETE – Deletes data from the database.

More resources:

SQL Overview

HTML Tutorial: Forms in HTML

HTML Tutorial: Tables

HTML Formatting tags

Structure of HTML Document


More actions