Question

In: Computer Science

On SQL explain Views, Union All,  Union, Truncate, Delete. And how we create Accounts in SQL Server?

On SQL explain Views, Union All,  Union, Truncate, Delete. And how we create Accounts in SQL Server?

Solutions

Expert Solution

Views:
Views provides encapsulation like it hides the original name of table. In view one can use more than one tables from database and add some sql functions, joins, where condition to get desire output. Basically it has rows and columns just like real table.

Example:
CREATE VIEW view_name AS
SELECT [column1], [column2] FROM table_name WHERE condition

You can also update and drop views.

Union All:
This combines result set of two or more select statments with duplication of rows. To use Union All you need to select same number of columns with same datatype and columns are specified in same order.

Example:
SELECT [Name],[Gender] FROM CITY1_TABLE WHERE [AGE] >18
UNION ALL  
SELECT [Name],[Gender] FROM CITY2_TABLE WHERE [AGE] >18

Union:
This combines result set of two or more select statements with distinct row. It never returns duplicate rows. To use Union you need to select same number of columns with same datatype and columns are specified in same order.

Example:
SELECT [Name][Age] FROM CITY1_TABLE where condition
UNION  
SELECT [Name],[Age] FROM CITY2_TABLE where condition

Truncate:
Truncate command will delete data present in table but it does not delete the table itself.

Example:
TRUNCATE TABLE table_name

Delete:
Delete command will delete existind records in table.

Example:
DELETE FROM table_name  WHERE condition

Create Account in SQL Server:

To create Login:
Navigate to Security -> Logins -> New Login and enter Login name, Password, Confirm Password and click OK to save.
or using query:
CREATE LOGIN login_name WITH PASSWORD = 'password';


Related Solutions

How to display in SQL Server, for example, all the author First Names are FIVE LETTERS...
How to display in SQL Server, for example, all the author First Names are FIVE LETTERS LONG if I have the Author Table. I used the WHERE LENGTH ua_fname=5   This is not returning names with 5 letters. Can someone please suggest to me the correct one?
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
What is a deadlock in SQL Server transaction processing? Are they preventable, if so how?
What is a deadlock in SQL Server transaction processing? Are they preventable, if so how?
Create by using Linux server • Create a file name it foo.txt • Remove all permissions...
Create by using Linux server • Create a file name it foo.txt • Remove all permissions from foo.txt • What happen if you try to read the file? • Change foo.txt permission to read and write only for owner • Change foo.txt permission to read for group • Change foo.txt permission to read and write everyone
In the Topic Materials, you learned about exporting SQL Server Data to Excel. Explain the two...
In the Topic Materials, you learned about exporting SQL Server Data to Excel. Explain the two options for exporting data using the SQL Server Import and Export Wizard, and provide examples of when each option should be selected.
Develop the SQL scripts that will create the tables and enforce all the appropriate constraints •...
Develop the SQL scripts that will create the tables and enforce all the appropriate constraints • Develop sample SQL scripts that will insert the data to the database (one row in each table) • Convert at least 2 entities to MongoDB Collections. Write the scripts that will Create the collection(s)
How to create a FTP server using python and TCP Ports How to create a FTP...
How to create a FTP server using python and TCP Ports How to create a FTP server using python and UDP Ports
Let A be a collection of sets, then We defined A’ = Union of all elements...
Let A be a collection of sets, then We defined A’ = Union of all elements of A. Definition: If A = NOT the union of C and D , where C and D are non empty sub-collection, such that C’ intersect D’ = empty Then A is coherent. Prove: if A is coherent then A’ is connected (i.e A’ is not the union of two separated sets in standard topology)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT