Hey visitors today we are continuing our SQL series in the previous part we learned about the intro of SQL
today we will continue with the series.
How to download SQL
after installation Go to https://www.microsoft.com/en-in/sql-server/sql-server-downloads for Microsoft SQL server download.
YOU ARE READY TO GO
Now we are starting with the SQL
1. Database
In MS SQL Server, two types of databases are available.
- System database
- User Databases
System Databases
System databases are created automatically when we install MS SQL Server.
Following is a list of system databases −
- Master
- Model
- MSDB
- Tempdb
User databases are created by users (Administrators,
developers, and testers who have access to create databases).
Method 1– Using T-SQL Script Create database <yourdatabasename>.
right-click on the databases folder. Click on the new database and the following screen will appear.
Write the database name and click ok.
and click OK. GUERILLATECK database will be created.
After creating database
DELETE A DATABASE
To remove your database from MS SQL Server, use drop database command. The following two methods can be used for this purpose.Method 1 – Using T-SQL Script
Following is the basic syntax for removing database from MS SQL Server.
Example:-
To remove the database name 'GUERILLATECK’, run the following query
Drop database <GUERILLATECK>
Following is the basic syntax for removing database from MS SQL Server.
Example:-
To remove the database name 'GUERILLATECK’, run the following query
Drop database <GUERILLATECK>
Tables in SQL.
Note *-before creating the table we have to run the following query because it is default selected to master(system-made database name) so we have to change it to our database
Syntax:- use<yourdatabasename>For eg:-
In SQL, a table is a collection of data organized in rows and columns. Tables are used to store data and represent real-world entities or concepts.
To create a table in SQL, you use the CREATE TABLE statement. The basic syntax for creating a table is as follows:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
);
for eg:-
INSERT statement in SQL Server is used for adding records in a table within the specified database.
INSERT INTO <table name> VALUES (value1, value2, ... );
For example:-
DROP TABLE table_name;
Note that when you drop a table, all data and indexes associated with the table will also be deleted. Therefore, it is important to use caution when dropping tables to avoid losing important data. It is also a good practice to back up your data regularly to prevent data loss in case of accidental drops or other disasters.
The SQL statement is used to delete one or more rows from a table in a relational database.
Syntx:-"DELETE FROM table_name [WHERE condition];"
No comments:
Post a Comment