database example 2 for coding, Exercises of Database Programming

example update modify , drop alter add,.....

Typology: Exercises

2018/2019

Uploaded on 04/01/2019

b2b2
b2b2 🇸🇦

3 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CIS 340 Database Systems LAB Works SQL Commands Dr. Asim Elshiekh
Page 1 of 3
Database Systems LAB Works
Structured Query Language (SQL) Commands
(1) Database Level Commands:
#
SQL Command
Description
Syntax
1
Create Database
To create a new database in MySQL.
Create Database DatabaseName;
2
Show Databases
To show all databases that are exist in MySQL.
Show Databases;
3
Connect
To connect to a database in MySQL.
Connect DatabaseName;
4
Use
To use and work on a database in MySQL.
Use DatabaseName;
5
Show Tables
To show all tables that are exist in a database.
Show Tables;
6
Drop Database
To remove an existing database from MySQL.
Drop Database DatabaseName;
pf3

Partial preview of the text

Download database example 2 for coding and more Exercises Database Programming in PDF only on Docsity!

Database Systems – LAB Works

Structured Query Language (SQL) Commands

( 1 ) Database Level Commands:

# SQL Command Description Syntax

1 Create Database To create a new database in MySQL. Create Database DatabaseName ; 2 Show Databases To show all databases that are exist in MySQL. Show Databases; 3 Connect To connect to a database in MySQL. Connect DatabaseName ; 4 Use To use and work on a database in MySQL. Use DatabaseName ; 5 Show Tables To show all tables that are exist in a database. Show Tables; 6 Drop Database To remove an existing database from MySQL. Drop Database DatabaseName ;

(2) Data Definition Language (DDL) Commands: mainly used for columns (of a table)

# SQL Command Description Syntax

1 Create Table To create a new table. Create Table TableName ( Column1 DataType1 [constraint1], Column2 DataType2 [constraint2], …… …… ColumnN DataTypeN [constraintN], Primary key ( ColumnName ), [ foreign key ( ColumnName ) References ParentTable ( ColumnName ) ON Delete Set Null ON Update Cascade ] ); 2 Drop Table To drop (remove) a table from a database. Drop Table TableName ; 3 Alter Table Add To add a new column to a table. Alter Table TableName Add ColumnName DataType ; 4 Alter Table Modify To modify (change) a column (name/type/size/constraint) in a table. Alter Table TableName Modify ColumnName DataType ; 5 Alter Table Drop To drop (remove) a column from a table. Alter Table TableName Drop ColumnName ; 6 Desc To show columns description of a table. Desc TableName ;