Home / Programming and Reporting / Create and Drop the Tables by SQL

Create and Drop the Tables by SQL

Create Table

  • What if we want to save our results in a new table?
  • We just need to add “create table table_name as” before the entire query that we write.
  • Create a new table by selecting product line =Motorcycles. Name the new table as motor_cycles_table
        create table classicmodels.motor_cycles_table as 
        select * 
        from classicmodels.products 
        where productLine='Motorcycles';

Drop Table

Drop Statement

  • Use drop statement
  • Create a temp table by selecting MSRP>2000
  • Drop the temp table
        create table classicmodels.temp as select * from classicmodels.products where MSRP>2000;
        Drop table classicmodels.temp;

About admin

Check Also

sql

Introduction to SQL- Basics

  SQL Basics Contents SQL Databases Sql Basics RMySql Sql Queries Sql Joins What is …

Leave a Reply

Your email address will not be published. Required fields are marked *