Udemy logo

SQL – An Intuitive Way to Interact with Database

sql insert into selectSQL has become very popular and is a universally acceptable database language. The benefit of SQL is that programmers and administrators need to learn one single language, and with minor adjustments, can apply it to a wide variety of database platforms, applications, and products. SQL is the standard language used to communicate with a relational database. You can use SQL for different database operations and one important function is to copy information from one table into another. SELECT INTO is the statement you use to copy data from one table and insert it into a new table.

Importance of Learning SQL

Every business has data and requires organizational methods or data management processes to maintain the data. Internet and high-speed, high-memory modern computers have brought a new perspective to the areas of data management and data handling. Modern databases with client/server configuration and web technologies are being used by businesses to effectively manage data and stay competitive in the market. So it is important to learn and understand SQL and how data structures are used to store information in an organization. SQL is the language you use to convey your needs to the database. You can request specific information from within a database by writing a query in SQL.

SELECT Statement and its Significance

SELECT statement represents Data Query Language (DQL) in SQL. A table is populated by using the INSERT statement. After this the SELECT statement is used in conjunction with the FROM clause to extract data from the database in an organized, readable manner. The SELECT keyword in a query is followed by a list of columns which you want to display as the result of a query output.

Apart from the keyword FROM, a SELECT statement can be followed by other keywords such as WHERE, ORDER BY to impose conditions with the SELECT statement.

Syntax for a SELECT Statement:

SELECT [column 1, column 2, …]

FROM source_table;

If you want to display all the columns of a table in the output, then use the symbol ‘*’ after SELECT.

SQL SELECT INTO Statement

The SELECT INTO statement selects data from one table and inserts it into a new table.

If we want to copy all columns of a table into a new table, then we use ‘*’ after the SELECT statement.

Syntax:

SELECT *

 INTO newtable [IN externaldb]

 FROM table1;

Example of SQL SELECT INTO Statement:

Here is an SQL SELECT INTO example to create a copy of the entire table of Vendors:

Syntax:

SELECT *

INTO Vendorcopy2014

FROM Vendors;

If we want to copy specific columns names into the new table then we enter:

Syntax:

SELECT [column 1, column 3, ….]

INTO newtable

FROM table1;

Here a new table will be created with the column-names and types as defined in the SELECT statement.

Example: To copy only the columns bearing Vendor Name and Country Name in the new table.

Syntax:

SELECT VendorName, CountryName

 INTO Vendorcopy2014

 FROM Vendors;

Example: Conditional copying of all vendor names only from the country Germany into the new table:

Syntax:

SELECT *

 INTO Vendorcopy2014

 FROM Vendors

 WHERE Country=’Germany’;

Limitations and Restrictions of SELECT and SELECT INTO

Here certain limitations and restrictions of a SELECT and SELECT….INTO statement have been discussed:

Conclusion

If you want to explore the SELECT statement further and want to decipher the effects of the different clauses associated with the SELECT statement, then SQL Queries 101 will help you to understand how to write basic SQL queries and other code statements. As you hone your knowledge and skills to become a successful database administrator and developer, you need to start writing customized SQL code to ensure you meet the user requirements in the most efficient manner. If you want to explore Oracle SQL and Oracle PL/SQL Programming then taking a peek into the course such as Introduction to Oracle SQL, or Oracle PL/SQL Tutorial – A Comprehensive Training Course may be a good idea.

Page Last Updated: May 2014

Top courses in SQL

SQL interview questions with business scenarios
Compylo ✅3000+ Students Worldwide, S K, Dr K
4.7 (233)
SQL for Healthcare
Mark Connolly
4.5 (514)
The Complete SQL Bootcamp: Go from Zero to Hero
Jose Portilla, Pierian Training
4.6 (213,694)
Bestseller
Advanced SQL : The Ultimate Guide (2024)
Database Masters Training | 250,000+ Students Worldwide, Code Star Academy
4.6 (5,974)
15 Days of SQL: The Complete SQL Masterclass 2024
Nikolai Schuler
4.7 (9,028)
Highest Rated
SQL - The Complete Developer's Guide (MySQL, PostgreSQL)
Academind by Maximilian Schwarzmüller, Maximilian Schwarzmüller, Manuel Lorenz
4.6 (1,703)
200+ SQL Interview Questions
Amarnath Reddy
4.4 (3,366)
Bestseller
SQL Programming Basics
Global Academy
4.5 (18,449)

More SQL Courses

SQL students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.

Request a demo