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

Day 2 - SQL Commands

The document provides an overview of data, types of data, and the structure of databases, including concepts like rows, columns, and tables. It details commands for managing databases and tables in RDBMS systems such as Oracle and MySQL, including creating, describing, and querying tables. Additionally, it includes examples of SQL commands for inserting and manipulating data within a table.

Uploaded by

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

Day 2 - SQL Commands

The document provides an overview of data, types of data, and the structure of databases, including concepts like rows, columns, and tables. It details commands for managing databases and tables in RDBMS systems such as Oracle and MySQL, including creating, describing, and querying tables. Additionally, it includes examples of SQL commands for inserting and manipulating data within a table.

Uploaded by

xajik41999
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

What is Data?

Types of Data

What is a Data Base?


Row/Record/Tuples
Columns/Fields/Attributes
Table Name - Entity
Table - Relation
Schema

RDBMS - Oracle, MySQL, Microsofit SQL Server, PostGreSQL, MS-Access.....


______________________________________________________________________________
To see the list of Databases present on the Server - SHOW DATABASES;
To create a Database - CREATE DATABASE database_name;
To clear the screen - \! cls
To connect to a database in the server - USE database_name;
To create a table: CREATE TABLE table_name( structure );
To see the Structure of the table - DESCRIBE table_name; or DESC table_name;
To Drop a Table - DROP TABLE table_name;
To Query/see the data in the table - SELECT * FROM table_name;
To Delete Data from the table - DELETE FROM table_name;

Eg: CREATE TABLE employee(


first_name varchar(20),
mid_name varchar(20),
last_name varchar(20),
age int,
salary int,
location varchar(20)
);

Inserting Data/Records into the Table:


INSERT INTO employee VALUES('Raja','Ram','Roy',32,35000,'Hyderabad');
INSERT INTO employee(first_name,last_name,age,salary,location)
VALUES('Mohan','Roy',28,35000,'Hyderabad');

CREATE TABLE employee(


first_name varchar(20) NOT NULL,
mid_name varchar(20),
last_name varchar(20) NOT NULL,
age int NOT NULL,
salary int NOT NULL,
location varchar(20) DEFAULT 'Hyderbad' NOT NULL
);

INSERT INTO employee(first_name,last_name,age,salary)


VALUES('Mohan','Roy',28,35000);

insert into employee(first_name,mid_name,last_name,age,salary,location)


values('Steve',null,"Mc'Donald",50,750000,'Chennai');
insert into employee(first_name,mid_name,last_name,age,salary,location)
values('Steve',null,'Mc\'Donald',50,750000,'Chennai');

Bulk Insert -
INSERT INTO employee(first_name,last_name,age,salary)
VALUES('Mohan','Roy',28,35000),('Raja','Ram',25,25000);

select * from employee;


+------------+----------+-----------+-----+--------+----------+
| first_name | mid_name | last_name | age | salary | location |
+------------+----------+-----------+-----+--------+----------+
| Mohan | NULL | Roy | 28 | 35000 | Hyderbad |
| Raja | NULL | Ram | 25 | 25000 | Hyderbad |
| Priya | NULL | Kapoor | 32 | 40000 | Hyderbad |
+------------+----------+-----------+-----+--------+----------+

INSERT INTO employee(first_name,last_name,age,salary,location)


VALUES('Rani','Sharma',28,35000,'Chennai'),
('Vamsi','Krishna',40,250000,'Bangalore');

You might also like