6. Database SQL
6. Database SQL
Database - Introduction
• A database is nothing but an organized collection of data.
• Data is organized into rows, columns and tables and it is
indexed to make it easier to find relevant information.
• All companies whether large or small use databases. So it
become necessary to develop project/software using any
programming language like python in such a manner which
can interface with such databases which support SQL.
• Generalised form of Interface of python with SQL Database
can be understood with the help of this diagram-
Advantages of DBMS
• The SQL ALTER TABLE command is used to add, delete or modify columns in an
existing table. You should also use the ALTER TABLE command to add and drop
various constraints on an existing table.
• The basic syntax of an ALTER TABLE command to add a New Column in an
existing table is as follows:
ALTER TABLE table_name ADD column_name datatype;
• The basic syntax of an ALTER TABLE command to DROP COLUMN in an existing
table is as follows:
ALTER TABLE table_name DROP COLUMN column_name;
• The basic syntax of an ALTER TABLE command to change the DATA TYPE of a
column in a table is as follows:
ALTER TABLE table_name MODIFY COLUMN column_name datatype;
• The basic syntax of an ALTER TABLE command to add a NOT NULL constraint to a
column in a table is as follows.
ALTER TABLE table_name MODIFY column_name datatype NOT NULL;