SlideShare a Scribd company logo
1 of 19
SQL TABLES
Supersfiserr:Hanan Kamal Abdulkarim Name:Arwa Wshyar Abdullkarem
How to create a table in Sql?
The table creation command requires:
•Name of the table
•Names of fields
•Definitions for each field
Here is generic SQL syntax to create a MySQL table:
Now, we will create following table in TUTORIALS database.
MySQL: is the most popular Open Source Relational
SQL database management system. MySQL is one of
the best RDBMS being used for developing web-based
software applications.
Here is an example, which creates tutorials_tbl:
Delet table in SQL
It is very easy to drop an existing MySQL table, but you need to
be very careful while deleting any existing table because data lost
will not be recovered after deleting a table.
Here is generic SQL syntax to drop a SQL table:
Here is an example, which deletes tutorials_tbl:
insert data into MySQL
This will use SQL INSERT INTO command to insert data into MySQL table
tutorials_tbl.
To insert data into MySQL table, you would need to use SQL INSERT
INTOcommand. You can insert data into MySQL table by using mysql>
prompt or by using any script like PHP.
To insert string data types, it is required to keep all the values into
double or single quote, for example:- "value".
Following example will create 3 records into tutorials_tbl table:
Updating Data from Command Prompt:
Here is generic SQL syntax of UPDATE command to modify
data into MySQL table:
•You can update one or more field altogether.
•You can specify any condition using WHERE clause.
•You can update values in a single table at a time.
Following example will update tutorial_title field for a record
having tutorial_id as 3.
Deleting Data from Command Prompt:
Here is generic SQL syntax of DELETE command to delete data
from a MySQL table:
•If WHERE clause is not specified, then all the records will be
deleted from the given MySQL table.
•You can specify any condition using WHERE clause.
•You can delete records in a single table at a time.
Following example will delete a record into tutorial_tbl whose
tutorial_id is 3.
MySQL ALTER Command
MySQL ALTER command is very useful when you want
to change a name of your table, any table field or if
you want to add or delete an existing column in a
table.
.
Dropping, Adding or Repositioning a Column:
Suppose you want to drop an existing column i from above MySQL table
then you will use DROP clause along with ALTER command as follows:
A DROP will not work if the column is the only one left in the
table.
To add a column, use ADD and specify the column
definition. The following statement restores
the i column to testalter_tbl:
Changing a Column Definition or Name:
To change a column's definition,
use MODIFY or CHANGE clause along with ALTER command.
For example, to change column c from CHAR(1) to CHAR(10),
do this:
Renaming a Table:
To rename a table, use the RENAME option of the ALTER TABLE
statement. Try out the following example to rename testalter_tbl
to alter_tbl.
THAT IS ALL….
thank you

More Related Content

What's hot (16)

Mysql alter-command
Mysql alter-commandMysql alter-command
Mysql alter-command
 
Mysql clone-tables
Mysql clone-tablesMysql clone-tables
Mysql clone-tables
 
SQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate TableSQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate Table
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
5. Group Functions
5. Group Functions5. Group Functions
5. Group Functions
 
Group by clause mod
Group by clause modGroup by clause mod
Group by clause mod
 
Indexes
IndexesIndexes
Indexes
 
Prabu's sql quries
Prabu's sql quries Prabu's sql quries
Prabu's sql quries
 
Clase 13 integridad modificada
Clase 13 integridad   modificadaClase 13 integridad   modificada
Clase 13 integridad modificada
 
Oracle views
Oracle viewsOracle views
Oracle views
 
Dml and ddl
Dml and ddlDml and ddl
Dml and ddl
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
Sql having clause
Sql having clauseSql having clause
Sql having clause
 
Database
DatabaseDatabase
Database
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
Babitha2.mysql
Babitha2.mysqlBabitha2.mysql
Babitha2.mysql
 

Similar to Sql tables

Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL ISankhya_Analytics
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasadpaddu123
 
Creating, altering and dropping tables
Creating, altering and dropping tablesCreating, altering and dropping tables
Creating, altering and dropping tablespunu_82
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowPavithSingh
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functionsfarwa waqar
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETEAbrar ali
 
SQL Queries - DDL Commands
SQL Queries - DDL CommandsSQL Queries - DDL Commands
SQL Queries - DDL CommandsShubhamBauddh
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...SakkaravarthiS1
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptxSheethal Aji Mani
 

Similar to Sql tables (20)

MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Creating, altering and dropping tables
Creating, altering and dropping tablesCreating, altering and dropping tables
Creating, altering and dropping tables
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
UNIT2.ppt
UNIT2.pptUNIT2.ppt
UNIT2.ppt
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
SQL Queries - DDL Commands
SQL Queries - DDL CommandsSQL Queries - DDL Commands
SQL Queries - DDL Commands
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
 
Sql commands
Sql commandsSql commands
Sql commands
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
 
chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 

Sql tables

  • 1. SQL TABLES Supersfiserr:Hanan Kamal Abdulkarim Name:Arwa Wshyar Abdullkarem
  • 2. How to create a table in Sql? The table creation command requires: •Name of the table •Names of fields •Definitions for each field Here is generic SQL syntax to create a MySQL table:
  • 3. Now, we will create following table in TUTORIALS database.
  • 4. MySQL: is the most popular Open Source Relational SQL database management system. MySQL is one of the best RDBMS being used for developing web-based software applications.
  • 5. Here is an example, which creates tutorials_tbl:
  • 6. Delet table in SQL It is very easy to drop an existing MySQL table, but you need to be very careful while deleting any existing table because data lost will not be recovered after deleting a table. Here is generic SQL syntax to drop a SQL table:
  • 7. Here is an example, which deletes tutorials_tbl:
  • 8. insert data into MySQL This will use SQL INSERT INTO command to insert data into MySQL table tutorials_tbl. To insert data into MySQL table, you would need to use SQL INSERT INTOcommand. You can insert data into MySQL table by using mysql> prompt or by using any script like PHP. To insert string data types, it is required to keep all the values into double or single quote, for example:- "value".
  • 9. Following example will create 3 records into tutorials_tbl table:
  • 10. Updating Data from Command Prompt: Here is generic SQL syntax of UPDATE command to modify data into MySQL table: •You can update one or more field altogether. •You can specify any condition using WHERE clause. •You can update values in a single table at a time.
  • 11. Following example will update tutorial_title field for a record having tutorial_id as 3.
  • 12. Deleting Data from Command Prompt: Here is generic SQL syntax of DELETE command to delete data from a MySQL table: •If WHERE clause is not specified, then all the records will be deleted from the given MySQL table. •You can specify any condition using WHERE clause. •You can delete records in a single table at a time.
  • 13. Following example will delete a record into tutorial_tbl whose tutorial_id is 3.
  • 14. MySQL ALTER Command MySQL ALTER command is very useful when you want to change a name of your table, any table field or if you want to add or delete an existing column in a table. .
  • 15. Dropping, Adding or Repositioning a Column: Suppose you want to drop an existing column i from above MySQL table then you will use DROP clause along with ALTER command as follows: A DROP will not work if the column is the only one left in the table.
  • 16. To add a column, use ADD and specify the column definition. The following statement restores the i column to testalter_tbl:
  • 17. Changing a Column Definition or Name: To change a column's definition, use MODIFY or CHANGE clause along with ALTER command. For example, to change column c from CHAR(1) to CHAR(10), do this:
  • 18. Renaming a Table: To rename a table, use the RENAME option of the ALTER TABLE statement. Try out the following example to rename testalter_tbl to alter_tbl.