Learning the SQL statements - Create statement

Learning the SQL statements - Create statement

Lesson Details:
June 29, 2020


I: Introduction

Hello



My name is ***** ***** I want to learn the basics of programming languages. This is my first attempt at this. The idea is to create an article on programming languages. I will need your help to get started. Once I have the outline, I will be able to write the article. Let me know if you can help.



Thanks

I: Background / Introduction

A: Programming languages are used in computing to tell computers what to do. It is a language that has instructions that are to be carried out by computers. It is used in daily life via electronic devices to control things like smart phones, gaming devices etc.



II: Body

A: Learning the sql statements - create statement

1) The CREATE statement in SQL lets you create databases, tables, views, procedures, functions, constraints, synonyms and sequences. You call these objects "objects" because they are abstractions of real-world objects. For example, you can create a table called Employees with fields for FirstName, LastName, City, State, Title, Salary, Department, ReportsTo, BirthDate and HireDate. You can then add data to the table using INSERT statements.[2]



2) The SQL CREATE statement can also be used to create other types of objects. For example, you can use it to create triggers or check constraints.[3] You use the ALTER statement to change the definition of an object after it has been created.[4]



3) A CREATE statement can create an object in either a database or in the current schema. When you create an object in the current schema, the default location is the schema owner's schema and no schema name is included in the CREATE statement. However, if you want to create an object using a schema other than your own, instead of including a schema name in the CREATE statement you must qualify the name of the object with the schema name.[5]



B: Learning about conditional statements - if then else

1) There are two kinds of “conditional” statements—the IF statement and the CASE statement. An IF statement lets you execute different pieces of code depending on whether a condition is true or false. The CASE statement lets you execute different pieces of code depending on which value (or values) is (are) stored in a column or expression.[8]



2) The IF statement has one condition and two possible actions: if the condition is true, execute this piece of code; if not, skip it and move on to the next line of code.[9]



3) A CASE statement has one or more conditions and one or more corresponding actions. Each condition is followed by a WHEN clause that specifies how to handle that case; each action is followed by an END clause that indicates when to stop executing those actions. If none of the conditions apply, a NULL value is returned.[10]



4) In a CASE statement, each condition must evaluate to a constant value.[11] If you want to test for something that isn’t constant—for example, a result from a function call or a value from a column—you must define the condition as a subquery. In a subquery, you test for a value stored in another table by including the table name and column list within parentheses after the word “WHERE”.[12]



C: Learning about loops - while loop and for loop

1) Loops are programming structures that allow you to repeat a group of statements multiple times. SQL supports two types of loops: WHILE loops and FOR loops.[13]



2) A WHILE loop executes a series of statements as long as a condition remains true.[14] While loops are often used to execute statements until a counter reaches a certain value.[15] To end a WHILE loop prematurely, use the BREAK statement.[16]



3) In a FOR loop, you specify three items: the initial value, the final value and the increment between those two values. FOR loops are often used to execute statements once for each row returned by the query.[17] To end a FOR loop prematurely, use the CONTINUE statement.[18]



loader
Course content