Skip to main content
Home
  • Tutorials
    • Quality Assurance
    • Software Development
    • Machine Learning
    • Data Science
  • About Us
  • Contact
programsbuzz facebook programsbuzz twitter programsbuzz linkedin
  • Log in

Main navigation

  • Tutorials
    • Quality Assurance
    • Software Development
    • Machine Learning
    • Data Science
  • About Us
  • Contact

MySQL: Create Table Using Another Table

Profile picture for user arilio666
Written by arilio666 on 12/27/2021 - 11:44

Today in this article we are gonna talk about creating tables from another existing table in our database using the AS clause which will recreate the existing table when used in this manner and create a backup or some can say clone of the existing table.

Syntax

create table TableName 
as
select * from existing_table;

So enough talk lets us see some of the ways we can create based on the existing one.

Creating Table Based On Existing Table

Same as the syntax the query follows the exact thing of creating the exact table structure of the existing table we provide in the select query statement.

CREATE TABLE Crypto 
as
SELECT * from crypto_price_list;

So we simply created a table based on the existing one called crypto_price_list and made the exact copy of it.

Creating Table Based On Two or More Existing Table Out Of Joins

CREATE TABLE CUSTORDER
as
SELECT order_id, o.customer_id, first_name, last_name from orders o JOIN customers c ON o.customer_id = c.customer_id;

  • So here we created a table based on the joins of two different tables orders and customers and created a table based on that joins output.
  • Here, in the same way, we can also customize our column name using the 'as' clause and create a table based on that output to get our very own customized column name-based table.
Related Content
MySQL: CREATE TABLE Statement
MySQL: INSERT INTO SELECT Statement
MySQL Tutorial
Tags
MySQL
  • Log in or register to post comments

Choose Your Technology

  1. Agile
  2. Apache Groovy
  3. Apache Hadoop
  4. Apache HBase
  5. Apache Spark
  6. Appium
  7. AutoIt
  8. AWS
  9. Behat
  10. Cucumber Java
  11. Cypress
  12. DBMS
  13. Drupal
  14. GitHub
  15. GitLab
  16. GoLang
  17. Gradle
  18. HTML
  19. ISTQB Foundation
  20. Java
  21. JavaScript
  22. JMeter
  23. JUnit
  24. Karate
  25. Kotlin
  26. LoadRunner
  27. matplotlib
  28. MongoDB
  29. MS SQL Server
  30. MySQL
  31. Nightwatch JS
  32. PactumJS
  33. PHP
  34. Playwright
  35. Playwright Java
  36. Playwright Python
  37. Postman
  38. Project Management
  39. Protractor
  40. PyDev
  41. Python
  42. Python NumPy
  43. Python Pandas
  44. Python Seaborn
  45. R Language
  46. REST Assured
  47. Ruby
  48. Selenide
© Copyright By iVagus Services Pvt. Ltd. 2023. All Rights Reserved.

Footer

  • Cookie Policy
  • Privacy Policy
  • Terms of Use