SlideShare a Scribd company logo
A. DDL Commands on MySQL:
 Create a database
Create database [database name];
 To delete a db.
Drop database [database name];
 To delete a table.
Drop table [table name];
 Delete a column.
Alter table [table name] drop column [column name];
ALTER TABLE employee DROP INDEX name_dept; - get rid of
 Add a new column to db.
Alter table [table name] add column [new column name] varchar (20);
ALTER TABLE employee ADD EmpId INT NOT NULL AUTO_INCREMENT PRIMARY
KEY;
 Change column name.
Alter table [table name] change [old column name] [new column] varchar (50);
 Make a unique column so you get no dupes.
Alter table [table name] add unique ([column name]);
 Make a column bigger.
Alter table [table name] modify [column name] varchar (3);
 Delete unique from table.
Alter table [table name] drop index [column name];
 Delete data from specific fields within a column:
Mysql> DELETE FROM mytable WHERE mycolumn="mydata";
 Rename a table within a specific database
Mysql> RENAME TABLE first TO second;
(Or)
Mysql> ALTER TABLE mytable rename as mynewtable;
 Create Table Example 1.
Create table [table name] (first name varchar(20),middleintial varchar(3),last
name varchar(35),suffix varchar(3),officeid varchar(10),userid
varchar(15),username varchar(8),email varchar(35),phone varchar(25),groups
varchar(15),datestamp date,timestamp time,pagemail varchar(255));
CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), species
VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
CREATE TABLE retired_employee (Name char(20) DEFAULT '' NOT NULL,Dept
char(10) DEFAULT '' NOT NULL,JobTitle char(20)UNIQUE name_dept
(Name,Dept));
CREATE UNIQUE index name_dept on employee (name,dept); - avoids duplicate
keys
 Create Table Example 2.
Create table [tablename] (personid int(50) not null auto_increment primary
key,firstname varchar(35),middlename varchar(50),lastname char(50) default
‘bato’;
Create table employees (employee_id integer, first_name varchar (20), last_name
Varchar (20)) type=MyISAM;
 Drop Database
Drop database databasename;
 Delete a row(s) from a table.
DELETE from [tablename] where [fieldname]=’whatever’;
 DROP TABLE
DROP TABLE TABLENAME;
 Simple column and field manipulation
Show columns within a table:
Mysql> DESC mytable;
(Or)
Mysql> SHOW COLUMNS FROM mytable;
B. DML Commands :
 Show all data in a table
SELECT * FROM [TABLENAME];
 Show certain selected rows with the value “whatever”
SELECT * FROM [tablename] where [field] =”whatever”;
 Show all records containing the name "Bob" AND the phone number '3444444'.
SELECT * FROM [TABLENAME] WHERE NAME=”bob” AND
phone_number=’3444444’;
 Show all records not containing the name "Bob" AND the phone number
'3444444' order by the phone_number field.
SELECT * FROM [TABLENAME] WHERE NAME! =”bob” and
phone_number=’3444444’ order by phone_number;
 Show all records starting with the letters 'bob' AND the phone number '3444444'.
SELECT * FROM [TABLENAME] WHERE NAME LIKE “bob%” and
phone_number=’3444444’;
 Show all records starting with the letters 'bob' AND the phone number '3444444'
limit to records 1 through 5.
SELECT * FROM [TABLENAME] WHERE NAME LIKE “bob%” and
phone_number=’3444444’ limit 1,5;
 Use a regular expression to find records. Use "REGEXP BINARY" to force case-
sensitivity. This finds any record beginning with a.
SELECT * FROM [TABLENAME] WHERE rec RLIKE “^a”;
 Show unique records.
SELECT DISTINCT [column name] FROM [TABLE NAME];
 Show selected records sorted in an ascending (asc) or descending (desc).
Select [col1], [col2] from [tablename] order by [col2] desc;
 Return number of rows.
SELECT COUNT (*) FROM [TABLENAME];
 Is there a way to query the DB to find out how many rows there are in all the
tables?
SELECT TABLE_NAME, TABLE_ROWS FROM `information_schema`.`tables` WHERE
`table_schema` = 'mrsqa4';
 Is there a way to get the count of rows in all tables in a mysql database without
running a SELECT count () on each table?
SELECT SUM (TABLE_ROWS) FROM INFORMATION_SCHEMA.TABLESWHERE
TABLE_SCHEMA = 'mrsqa4';
 Sum column.
SELECT SUM (*) FROM [TABLENAME];
 Show the last 200 queries to your database with the sample table name "queries"
and the sample field "query_id"
Mysql> SELECT * FROM queries ORDER BY query_id DESC LIMIT 200;
 Show data within a specific table in a previously selected database
Mysql> SELECT * FROM table name;
 Select data within a specific table in a previously selected database:
Mysql> SELECT * FROM mytable WHERE mycolumn='mydata' ORDER BY
mycolumn2;
 Join tables on common columns.
Select lookup.illustrationid, looup.personid,person.birthday from lookup
Left join person on lookup.personid=person.personid=statement to join
Birthday in person table with primary illustrationid;
MySQL> SELECT DISTINCT dept FROM bedrock;
MySQL> SELECT * FROM pet WHERE species = "snake" OR species = "bird";
MySQL> SELECT * FROM pet WHERE species = "dog" AND sex = "f";
MySQL> SELECT * FROM pet WHERE birth >= "1998-1-1";
MySQL> SELECT name, birth FROM pet ORDER BY birth DESC;
MySQL> SELECT * FROM pet WHERE name LIKE "b%";
MySQL> SELECT * FROM pet WHERE name REGEXP "^b";
MySQL> SELECT species, COUNT(*) FROM pet GROUP BY species;
MySQL> SELECT MAX(article) AS article FROM shop;
MySQL> SELECT * FROM employee WHERE name LIKE "%Sm%";
MySQL> SELECT * FROM employee WHERE name REGEXP "^Ja";
Insert:
MySQL> INSERT INTO employee VALUES ("Jane Smith","Sales","Custome Rep");
MySQL> INSERT INTO employee VALUES ('Jane Smith','Sales','Account Manager');
MySQL> INSERT INTO employee VALUES ('Jane smith’,’Engineein’,’Manager’);
MySQL> UPDATE employee SET dept='HR' WHERE name='Jane Smith';
 Insert data into a table and its columns within a specific database:
mysql> INSERT INTO mytable VALUES('column1data','column2data',
'column3data','column4data','column5data','column6data',
'column7data','column8data','column9data');
 Update data in a specific table, column, field:
Mysql> UPDATE mytable SET column1="mydata" WHERE column2="mydata";

More Related Content

What's hot

DML Commands
DML CommandsDML Commands
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Sql DML
Sql DMLSql DML
Sql DML
Vikas Gupta
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
HudaRaghibKadhim
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Sql commands
Sql commandsSql commands
Sql commands
Mohd Tousif
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
8. sql
8. sql8. sql
8. sql
khoahuy82
 
ADBMS Unit-II c
ADBMS Unit-II cADBMS Unit-II c
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commandsBelle Wx
 
Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
Abdul Rehman
 
SQL
SQLSQL

What's hot (19)

DML Commands
DML CommandsDML Commands
DML Commands
 
Sql commands
Sql commandsSql commands
Sql commands
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Sql DML
Sql DMLSql DML
Sql DML
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Sql commands
Sql commandsSql commands
Sql commands
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
 
Les10
Les10Les10
Les10
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
8. sql
8. sql8. sql
8. sql
 
ADBMS Unit-II c
ADBMS Unit-II cADBMS Unit-II c
ADBMS Unit-II c
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
 
SQL
SQLSQL
SQL
 
Les11 Including Constraints
Les11 Including ConstraintsLes11 Including Constraints
Les11 Including Constraints
 
SQL Views
SQL ViewsSQL Views
SQL Views
 

Similar to Ddl commands

Sql cheat sheet
Sql cheat sheetSql cheat sheet
Sql cheat sheet
solgenomics
 
MY SQL
MY SQLMY SQL
MY SQL
sundar
 
supporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tablesupporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered table
Mahabubur Rahaman
 
Mysql Statments
Mysql StatmentsMysql Statments
Mysql Statments
SHC
 
Farheen abdul hameed ip project (MY SQL);
Farheen abdul hameed ip project (MY SQL);Farheen abdul hameed ip project (MY SQL);
Farheen abdul hameed ip project (MY SQL);
abdul talha
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01sagaroceanic11
 
Oraclesql
OraclesqlOraclesql
Oraclesql
Priya Goyal
 
Basic sql(oracle) queries
Basic sql(oracle) queriesBasic sql(oracle) queries
Basic sql(oracle) queries
Harish Gyanani
 
Sql commands
Sql commandsSql commands
Sql commands
Christalin Nelson
 
MS SQL Database basic
MS SQL Database basicMS SQL Database basic
MS SQL Database basic
wali1195189
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinhwebhostingguy
 
MySQL.pptx comuterscience from kvsbbsrs.
MySQL.pptx comuterscience from kvsbbsrs.MySQL.pptx comuterscience from kvsbbsrs.
MySQL.pptx comuterscience from kvsbbsrs.
sudhasuryasnata06
 
Avinash database
Avinash databaseAvinash database
Avinash databaseavibmas
 
SQL WORKSHOP::Lecture 10
SQL WORKSHOP::Lecture 10SQL WORKSHOP::Lecture 10
SQL WORKSHOP::Lecture 10Umair Amjad
 

Similar to Ddl commands (20)

Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 
Sql cheat sheet
Sql cheat sheetSql cheat sheet
Sql cheat sheet
 
MY SQL
MY SQLMY SQL
MY SQL
 
supporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tablesupporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered table
 
Mysql Statments
Mysql StatmentsMysql Statments
Mysql Statments
 
Farheen abdul hameed ip project (MY SQL);
Farheen abdul hameed ip project (MY SQL);Farheen abdul hameed ip project (MY SQL);
Farheen abdul hameed ip project (MY SQL);
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Basic sql(oracle) queries
Basic sql(oracle) queriesBasic sql(oracle) queries
Basic sql(oracle) queries
 
Sql commands
Sql commandsSql commands
Sql commands
 
MS SQL Database basic
MS SQL Database basicMS SQL Database basic
MS SQL Database basic
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
dbms.pdf
dbms.pdfdbms.pdf
dbms.pdf
 
MySQL.pptx comuterscience from kvsbbsrs.
MySQL.pptx comuterscience from kvsbbsrs.MySQL.pptx comuterscience from kvsbbsrs.
MySQL.pptx comuterscience from kvsbbsrs.
 
Avinash database
Avinash databaseAvinash database
Avinash database
 
SQL WORKSHOP::Lecture 10
SQL WORKSHOP::Lecture 10SQL WORKSHOP::Lecture 10
SQL WORKSHOP::Lecture 10
 
Bibashsql
BibashsqlBibashsql
Bibashsql
 
Sql
SqlSql
Sql
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 

More from Vasudeva Rao

Upgrading mysql version 5.5.30 to 5.6.10
Upgrading mysql version 5.5.30 to 5.6.10Upgrading mysql version 5.5.30 to 5.6.10
Upgrading mysql version 5.5.30 to 5.6.10
Vasudeva Rao
 
My sql storage engines
My sql storage enginesMy sql storage engines
My sql storage enginesVasudeva Rao
 
Mater,slave on mysql
Mater,slave on mysqlMater,slave on mysql
Mater,slave on mysqlVasudeva Rao
 
Inno db datafiles backup and retore
Inno db datafiles backup and retoreInno db datafiles backup and retore
Inno db datafiles backup and retoreVasudeva Rao
 
Convert language latin1 to utf8 on mysql
Convert language latin1 to utf8 on mysqlConvert language latin1 to utf8 on mysql
Convert language latin1 to utf8 on mysqlVasudeva Rao
 
Database migration
Database migrationDatabase migration
Database migrationVasudeva Rao
 
Performence tuning
Performence tuningPerformence tuning
Performence tuning
Vasudeva Rao
 
All types of backups and restore
All types of backups and restoreAll types of backups and restore
All types of backups and restoreVasudeva Rao
 
Multiple instances second method
Multiple instances second methodMultiple instances second method
Multiple instances second method
Vasudeva Rao
 
Multiple instance on windows
Multiple instance on windowsMultiple instance on windows
Multiple instance on windows
Vasudeva Rao
 
Multiple instances on linux
Multiple instances on linuxMultiple instances on linux
Multiple instances on linux
Vasudeva Rao
 
Postgre sql run book
Postgre sql run bookPostgre sql run book
Postgre sql run book
Vasudeva Rao
 

More from Vasudeva Rao (12)

Upgrading mysql version 5.5.30 to 5.6.10
Upgrading mysql version 5.5.30 to 5.6.10Upgrading mysql version 5.5.30 to 5.6.10
Upgrading mysql version 5.5.30 to 5.6.10
 
My sql storage engines
My sql storage enginesMy sql storage engines
My sql storage engines
 
Mater,slave on mysql
Mater,slave on mysqlMater,slave on mysql
Mater,slave on mysql
 
Inno db datafiles backup and retore
Inno db datafiles backup and retoreInno db datafiles backup and retore
Inno db datafiles backup and retore
 
Convert language latin1 to utf8 on mysql
Convert language latin1 to utf8 on mysqlConvert language latin1 to utf8 on mysql
Convert language latin1 to utf8 on mysql
 
Database migration
Database migrationDatabase migration
Database migration
 
Performence tuning
Performence tuningPerformence tuning
Performence tuning
 
All types of backups and restore
All types of backups and restoreAll types of backups and restore
All types of backups and restore
 
Multiple instances second method
Multiple instances second methodMultiple instances second method
Multiple instances second method
 
Multiple instance on windows
Multiple instance on windowsMultiple instance on windows
Multiple instance on windows
 
Multiple instances on linux
Multiple instances on linuxMultiple instances on linux
Multiple instances on linux
 
Postgre sql run book
Postgre sql run bookPostgre sql run book
Postgre sql run book
 

Recently uploaded

GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 

Recently uploaded (20)

GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 

Ddl commands

  • 1. A. DDL Commands on MySQL:  Create a database Create database [database name];  To delete a db. Drop database [database name];  To delete a table. Drop table [table name];  Delete a column. Alter table [table name] drop column [column name]; ALTER TABLE employee DROP INDEX name_dept; - get rid of  Add a new column to db. Alter table [table name] add column [new column name] varchar (20); ALTER TABLE employee ADD EmpId INT NOT NULL AUTO_INCREMENT PRIMARY KEY;  Change column name. Alter table [table name] change [old column name] [new column] varchar (50);  Make a unique column so you get no dupes. Alter table [table name] add unique ([column name]);  Make a column bigger.
  • 2. Alter table [table name] modify [column name] varchar (3);  Delete unique from table. Alter table [table name] drop index [column name];  Delete data from specific fields within a column: Mysql> DELETE FROM mytable WHERE mycolumn="mydata";  Rename a table within a specific database Mysql> RENAME TABLE first TO second; (Or) Mysql> ALTER TABLE mytable rename as mynewtable;  Create Table Example 1. Create table [table name] (first name varchar(20),middleintial varchar(3),last name varchar(35),suffix varchar(3),officeid varchar(10),userid varchar(15),username varchar(8),email varchar(35),phone varchar(25),groups varchar(15),datestamp date,timestamp time,pagemail varchar(255)); CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE); CREATE TABLE retired_employee (Name char(20) DEFAULT '' NOT NULL,Dept char(10) DEFAULT '' NOT NULL,JobTitle char(20)UNIQUE name_dept (Name,Dept)); CREATE UNIQUE index name_dept on employee (name,dept); - avoids duplicate keys  Create Table Example 2. Create table [tablename] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastname char(50) default ‘bato’;
  • 3. Create table employees (employee_id integer, first_name varchar (20), last_name Varchar (20)) type=MyISAM;  Drop Database Drop database databasename;  Delete a row(s) from a table. DELETE from [tablename] where [fieldname]=’whatever’;  DROP TABLE DROP TABLE TABLENAME;  Simple column and field manipulation Show columns within a table: Mysql> DESC mytable; (Or) Mysql> SHOW COLUMNS FROM mytable; B. DML Commands :  Show all data in a table SELECT * FROM [TABLENAME];  Show certain selected rows with the value “whatever” SELECT * FROM [tablename] where [field] =”whatever”;  Show all records containing the name "Bob" AND the phone number '3444444'. SELECT * FROM [TABLENAME] WHERE NAME=”bob” AND phone_number=’3444444’;
  • 4.  Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field. SELECT * FROM [TABLENAME] WHERE NAME! =”bob” and phone_number=’3444444’ order by phone_number;  Show all records starting with the letters 'bob' AND the phone number '3444444'. SELECT * FROM [TABLENAME] WHERE NAME LIKE “bob%” and phone_number=’3444444’;  Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5. SELECT * FROM [TABLENAME] WHERE NAME LIKE “bob%” and phone_number=’3444444’ limit 1,5;  Use a regular expression to find records. Use "REGEXP BINARY" to force case- sensitivity. This finds any record beginning with a. SELECT * FROM [TABLENAME] WHERE rec RLIKE “^a”;  Show unique records. SELECT DISTINCT [column name] FROM [TABLE NAME];  Show selected records sorted in an ascending (asc) or descending (desc). Select [col1], [col2] from [tablename] order by [col2] desc;  Return number of rows. SELECT COUNT (*) FROM [TABLENAME];  Is there a way to query the DB to find out how many rows there are in all the tables? SELECT TABLE_NAME, TABLE_ROWS FROM `information_schema`.`tables` WHERE `table_schema` = 'mrsqa4';
  • 5.  Is there a way to get the count of rows in all tables in a mysql database without running a SELECT count () on each table? SELECT SUM (TABLE_ROWS) FROM INFORMATION_SCHEMA.TABLESWHERE TABLE_SCHEMA = 'mrsqa4';  Sum column. SELECT SUM (*) FROM [TABLENAME];  Show the last 200 queries to your database with the sample table name "queries" and the sample field "query_id" Mysql> SELECT * FROM queries ORDER BY query_id DESC LIMIT 200;  Show data within a specific table in a previously selected database Mysql> SELECT * FROM table name;  Select data within a specific table in a previously selected database: Mysql> SELECT * FROM mytable WHERE mycolumn='mydata' ORDER BY mycolumn2;  Join tables on common columns. Select lookup.illustrationid, looup.personid,person.birthday from lookup Left join person on lookup.personid=person.personid=statement to join Birthday in person table with primary illustrationid; MySQL> SELECT DISTINCT dept FROM bedrock; MySQL> SELECT * FROM pet WHERE species = "snake" OR species = "bird"; MySQL> SELECT * FROM pet WHERE species = "dog" AND sex = "f"; MySQL> SELECT * FROM pet WHERE birth >= "1998-1-1"; MySQL> SELECT name, birth FROM pet ORDER BY birth DESC; MySQL> SELECT * FROM pet WHERE name LIKE "b%"; MySQL> SELECT * FROM pet WHERE name REGEXP "^b";
  • 6. MySQL> SELECT species, COUNT(*) FROM pet GROUP BY species; MySQL> SELECT MAX(article) AS article FROM shop; MySQL> SELECT * FROM employee WHERE name LIKE "%Sm%"; MySQL> SELECT * FROM employee WHERE name REGEXP "^Ja"; Insert: MySQL> INSERT INTO employee VALUES ("Jane Smith","Sales","Custome Rep"); MySQL> INSERT INTO employee VALUES ('Jane Smith','Sales','Account Manager'); MySQL> INSERT INTO employee VALUES ('Jane smith’,’Engineein’,’Manager’); MySQL> UPDATE employee SET dept='HR' WHERE name='Jane Smith';  Insert data into a table and its columns within a specific database: mysql> INSERT INTO mytable VALUES('column1data','column2data', 'column3data','column4data','column5data','column6data', 'column7data','column8data','column9data');  Update data in a specific table, column, field: Mysql> UPDATE mytable SET column1="mydata" WHERE column2="mydata";