Basic syntax Flashcards

1
Q

what is select for?

A

The SELECT statement in SQL is used to retrieve or fetch data from a database table. It allows you to query the database and retrieve specific columns or all columns from one or more tables. The data returned by the SELECT statement is stored in a result table, also known as a result set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is fetch?

A

Fetch refers to the retrieval of data by a software program, script, or hardware device. It is the process of obtaining data from a source and moving it to another location or displaying it on a screen.
In SQL, the SELECT statement is used to fetch data from a database table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is insert into for?

A

The INSERT INTO statement is used to insert new rows of data in a table

INSERT INTO table_name (column1, column2, column3)

VALUES (value1, value2, value3);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is the UPDATE statement for?

A

The UPDATE statement is used to modify existing records in a table. It is a part of Data Manipulation Language (DML), which only modifies the data present in a table without affecting the table’s structure.

UPDATE table_name

SET column1 = value1, column2 = value2, …

WHERE condition;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between the UPDATE statement and the INSERT statement in SQL?

A

UPDATE statement:
+Modifies the existing records in a table.
+Changes the values of one or more columns in one or more rows.
+Uses the WHERE clause to specify which rows to update.
+Does not affect the table’s structure.

INSERT statement:
+Adds new records to a table.
+Inserts one or more rows into a table.
+Does not require a WHERE clause.
+Does not modify existing records.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the The DELETE statement for?

A

The DELETE statement in SQL is used to remove existing records from a table. It allows you to delete one or more rows from a table based on specified conditions.

DELETE FROM table_name WHERE condition;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is The CREATE TABLE statement for?

A

The CREATE TABLE statement is used to create a new table in a database

CREATE TABLE table_name (
column1 datatype
constraints,
column2 datatype
constraints,
column3 datatype
constraints
);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is The ALTER TABLE statement for?

A

The ALTER TABLE statement in SQL is used to modify the structure of an existing table. It allows you to add, modify, or delete columns in a table, as well as add or remove various constraints on existing tables.

– To add a column
ALTER TABLE table_name
ADD column_name datatype;

– To delete/drop column
ALTER TABLE table_name

DROP COLUMN column_name;

– To modify existing column
ALTER TABLE table_name
MODIFY COLUMN
column_name datatype;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what are constrains?

A

Constraints in SQL are rules that are applied to the data in a table. They are used to limit the type of data that can be stored in a particular column in a table. Constraints help to maintain the accuracy, integrity, and reliability of a table’s data. They can be created at a column or table level. If you declare constraints at the column level, they will apply to a single column. On the other hand, if you declare them at the table level, they will apply to more than one column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is the The DROP TABLE statement for?

A

The DROP statement in SQL is used to delete or remove entities such as databases, tables, columns, indexes, constraints, etc. When an entity is dropped, all its related information (data and metadata) will be deleted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
A

DROP command:
+The DROP command is a Data Definition Language (DDL) command.
+It is used to remove entities such as databases, tables, columns, indexes, constraints, etc.
+When an entity is dropped, all its related information (data and metadata) will be deleted.
+For example, dropping a table will delete the table itself, along with its data, indexes, constraints, and triggers.
+The DROP command is irreversible and permanently removes the entity from the database.
+Syntax: DROP entity_type entity_name;
DELETE command:
+The DELETE command is a Data Manipulation Language (DML) command.
+It is used to remove specific rows or records from a table based on specified conditions.
+The DELETE command is used to selectively remove data from a table, while keeping the table structure intact.
+It can be used with the WHERE clause to specify the conditions for deleting specific rows.
+The DELETE command is reversible, as it can be rolled back if executed within a transaction.
+Syntax: DELETE FROM table_name WHERE condition;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly