0% found this document useful (0 votes)
2 views2 pages

SQL Database

The document outlines various SQL commands for managing a database, including creating, updating, and deleting databases and tables. It provides examples of creating a table for employees, selecting data, renaming tables, altering table structures, and inserting records. Additionally, it demonstrates how to modify columns and drop them as needed.

Uploaded by

erize.805539
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

SQL Database

The document outlines various SQL commands for managing a database, including creating, updating, and deleting databases and tables. It provides examples of creating a table for employees, selecting data, renaming tables, altering table structures, and inserting records. Additionally, it demonstrates how to modify columns and drop them as needed.

Uploaded by

erize.805539
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

//CREATE DATABASE

Show databases;

Create database mydb;

Use mydb;

//delete database

Drop database mydb;

Show databases;

//update database

Alter database mydb read only = 1;

Drop database mydb;//error

Alter database mydb read only = 0;

//CREATE TABLE

Create table employees(

Employee_id INT , first_name VARCHAR(30), last_name VARCHAR(30), SALARY DECIMAL(10,2),


hire_date DATE);

//SELECT TABLE

SELECT * FROM employees;

Rename TABLE EMPLOYEES TTTTO WORKERS;

Rename table workers to employees;

Drop table employees;

//update table

Alter table employees add phone_num varchar(15);

Select * from employees;

Alter table employees rename column phone_num to email;


Alter table employees modify column email varchar(100);

Alter table employees modify email varchar(100) after last_name()

Select * from employees;

Alter table employees modify email varchar(100) first;

//drop column

Alter table employees drop column email;

//insert queries

INSERT INTO employees

VALUES (101,”Eric”, “Rai”,90000, “2026-06-04”),

(102,”Anushka”, “katwal”,100000,”2025-01-03”),(),(),();

You might also like