Found 25 Questions For SQL

How to change a table name in SQL ?

Updated on 12-Dec-2021 20:55:05
This is the command to change a table name in SQL: ALTER TABLE table_name RENAME TO new_table_name; We will start off by giving the keywords ALTER TABLE, then we will follow it up by giving the original name of the table, after that, we will give in the keywords RENAME TO and finally, we will give the new table name. For example, if we want to change the “employee” table to “employee_information”, this will be the command: ALTER TABLE employee RENAME TO employee_information... Read More

How to delete a table in SQL ?

Updated on 12-Dec-2021 20:41:30
There are two ways to delete a table from sql: DROP and TRUNCATE. The DROP TABLE command is used to completely delete the table from the database. This is the command: DROP TABLE table_name; The above command will completely delete all the data present in the table along with the table itself. But if we want to delete only the data present in the table but not the table itself, then we will use the truncate command: DROP TABLE table_name ; ... Read More

How to create a table in SQL ?

Updated on 12-Dec-2021 20:35:52
The command to create a table in sql is extremely simple: CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, .... ); We will start off by giving the keywords, CREATE TABLE, then we will give the name of the table. After that in braces, we will list out all the columns along with their datatypes. For example, if we want to create a simple employee table: CREATE TABLE employee ( name varchar(25), age int, gender varchar(25), .... ); ... Read More

What is SQL ?

Updated on 12-Dec-2021 20:35:18
SQL stands for Structured Query Language. It is the primary language to interact with databases. With the help of SQL, we can extract data from a database, modify this data and also update it whenever there is a requirement. This query language is evergreen and is widely used across industries. For example, if a company has records of all the details of their employees in the database. With the help of SQL, all of this data can be queried to find out valuable insights in a short span of time... Read More

How to Create a Table in SQL – Postgres and MySQL Example Query

Updated on 27-Oct-2021 16:44:42
Knowing how to create tables in SQL is an important and fundamental concept. In this tutorial, I will walk you through the SQL syntax for the CREATE TABLE statement using code examples for both PostgreSQL and MySQL. Basic CREATE TABLE Syntax Here is the basic syntax for the CREATE TABLE statement: CREATE TABLE table_name( column1 data_type column_constraint, column2 data_type column_constraint, column3 data_type column_constraint, column4 data_type column_const... Read More