TYPES OF COMMAND IN SQL
- CREATE: This command is used to create a new database object such as a table, view, index, or sequence.
- DROP: This command is used to delete an existing database object such as a table, view, index, or sequence.
2)Data Manipulation Language (DML): Data Manipulation Language (DML) is a set of SQL commands used to manipulate the data stored in a database. DML commands are used to insert, update, delete, and retrieve data from tables. Here are some common DML commands used in SQL:
- SELECT: Data can be retrieved from one or more tables using the SELECT command.You can specify the columns and rows to be returned using various clauses like WHERE, ORDER BY, GROUP BY, etc.
- INSERT: This command is used to insert new rows of data into a table. You can specify the columns and values to be inserted.
Data can be obtained from one or more tables using the SELECT statement in SQL. In a SELECT statement, the following fundamental syntax is used:
FROM table_name
WHERE COLUMN_NAME = value;
FOR EXAMPLE:-
SELECT column1, column2, ...
FROM table_name
WHERE some_column = some_value;
FOR EXAMPLE:-
- Primary Key: A column or group of columns known as a primary key uniquely identifies each row in a table.
It is used to enforce entity integrity, which means that each row in the table represents a unique entity. Primary keys must be unique and cannot contain null values.
- Foreign Key: A column or group of columns that make reference to the primary key of another table are known as foreign keys. It is used to enforce referential integrity, which means that the values in the foreign key column(s) must match the values in the primary key column(s) of the referenced table. Foreign keys are used to establish relationships between tables.
- Unique Key: A unique key is a column or set of columns that uniquely identifies each row in a table, similar to a primary key. However, unlike a primary key, a unique key can contain null values. Unique keys are used to enforce entity integrity, just like primary keys.
The names of things like databases, tables, or columns are where identifiers are most frequently employed.
Rules for identifiers:-
* begin with a Unicode letter or an underscore (_). Letters, underscores, numerals (0–9), or dollar signs ($) are all acceptable as additional characters.
* keyword is not accepted as an identifier.
These are reserved words and can have specific meanings in statements to perform various operations in the database.
Views are database objects with no value; that's why it does not store physically. Views are a great tool for hiding or abstracting complex queries because of this characteristic.
Although it does not actually have rows and columns, it resembles one. Consequently, it can be said that its contents are based on the base table. Although it doesn't have any data of its own, it operates similarly to the base table. Its name is always unique, like tables. The views differ from tables as they are definitions that are created on top of other tables (or views). If any changes occur in the underlying table, the same changes are reflected in the views also.
Implementing the security mechanism is the main function of views in SQL Server. Specific columns and rows in tables are hidden from users by this. It only shows the data returned by the query that was declared when the view was created. The user is never made aware of the remaining details.
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Rename views
SP_RENAME View_Old_Name, View_New_Name
Drop Views in SQL Server
DROP VIEW [IF EXISTS] schema_name.view_name;
DROP VIEW Student
so that's it for today guys, follow us to learn more about SQL topics.....
happy learning.....
Great....
ReplyDeleteGreat Content
ReplyDeletealways support you
ReplyDelete