Using the Schema - data/statistics Write down the following SQL queries. Assume appropriate data types for each attribute by yourself. 1) Create Bill table. 2)Assume you forgot to set SID as foreign key during creation of Bill table, by default SID is declared as null.Now you have to declare SID as foreign key. 3)Add constraint on names of customer that ensures that names must start with alphabet.
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
Using the Schema - data/statistics Write down the following SQL queries. Assume appropriate data types for each attribute by yourself.
1) Create Bill table.
2)Assume you forgot to set SID as foreign key during creation of Bill table, by default SID is declared as null.Now you have to declare SID as foreign key.
3)Add constraint on names of customer that ensures that names must start with alphabet.
4)Delete constraint that was added in statement 3.
5)Add a new column in any one of the tables.
6)Delete the added column in statement 5
7)Show name of all those customers who have placed order after 23 June 2014 using subquery.
8)Show the data of those customers to who items were sold with SID 1 or 3 or 6
9)Show names of customers and items names of items sold to him
10)Make a vertical partition on customer table in such a way that changes in partitioned portion must be reflected on original table.
11) Update the city of customer as ‘Lahore’ where customer id is 3
12)Delete all those records of Items table whose price is between 15 and 240
13)Insert a record in any one of the tables
14)Change data type of name of customer to varchar(20)
15)Display details of all those items that are not sold yet
Step by step
Solved in 2 steps with 6 images