Some of the most common ones are: INT, DECIMAL, DATETIME, VARCHAR, NVARCHAR, FLOAT, and BIT.įrom our example above, this could look like the following code: CREATE TABLE engineering ( There are a variety of datatypes that we can use. It gives the table a name, and the different columns we want our table to have are also passed in. This query creates a new table inside the database. SQL CREATE TABLE Statement CREATE TABLE table_name ( To create a database named engineering, we can use the following code: CREATE DATABASE engineering We CREATE information in the database, we READ/Retrieve that information from the database, we UPDATE/manipulate it, and if we want we can DELETE it.īelow we'll look at some basic SQL queries along with their syntax to get started. Basic SQL QueriesĪll the operatations that you can do with data follow the CRUD acronym.ĬRUD stands for the 4 main operations we perform when we query a database: Create, Read, Update, and Delete. These rows would define and provide info about one person on the Engineering team. For example a row would include entries under employee_id, first_name, last_name, email, salary, and country. Tables also consist of rows, which are individual entries into the table. For example the Engineering table can have columns that define a single attribute like employee_id, first_name, last_name, email, country, and salary. To see the different columns use Describe Engineering. +-+Īll tables then consist of different columns that describe the data. The tables can be Engineering, Product, Marketing, and Sales for the different teams the company has. Taking the example from above, to see the different tables in the employees database, we can do SHOW TABLES in employees. The output will look something like this: +-+Ī single database can have multiple tables. To see a full list of their databases, we can type SHOW DATABASES and we can zone in on the Employees database. So to fetch the desired data we need to get specific.įor example, a remote company can have multiple databases. A field is a single piece of data within a row. Each table has columns that describe the data in them, and rows that contain the actual data. The Basic Structure of a Databaseīefore we get started, you should understand the hierarchy of a database.Īn SQL database is a collection of related information stored in tables. In this article, we'll look at some of the most common SQL commands for beginners and how you can use them to effectively query a database – that is, make a request for specific information. You can use SQL commands to create a table in a database, to add and make changes to large amounts of data, to search through it to quickly find something specific, or to delete a table all together. SQL consists of commands and declarative statements that act as instructions to the database so it can perform tasks. SQL stands for Structured Query Language and is a language that you use to manage data in databases.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |