This tutorial is all about Sequence In Oracle Database. In this SQL Tutorial you will learn How to create a sequence How to populate a Primary key column (auto increment in Oracle) using Sequence How to drop a sequence
------------------------------------------------------------------------
►►►LINKS◄◄◄
Blog : http://bit.ly/sql-sequence-in-oracle-database-rebellionrider-manish-sharma
Previous Tutorial
► How To Insert Data into Table using SQL Developer
http://youtu.be/YYQCSV6MzTk
► INSERT INTO Command
http://youtu.be/uQXgqFtxI_k
► How to copy /Insert data into a table from another table
http://youtu.be/m3Ep8tAMqok
-------------------------------------------------------------------------
►►►Help Me In Getting A Job◄◄◄
►Help Me In Getting A Good Job By Connecting With Me on My LinkedIn and Endorsing My Skills. All My Contact Info is Down Below. You Can Also Refer Me To Your Company
Thanks
-------------------------------------------------------------------------
Copy Cloud referral link || Use this link to join copy cloud and get 20GB of free storage
https://copy.com?r=kb4rc1
--------------------------------------------------------------------------
►Make sure you SUBSCRIBE and be the 1st one to see my videos!
--------------------------------------------------------------------------
Amazon Wishlist: http://bit.ly/wishlist-amazon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
►►►Find me on Social Media◄◄◄
Follow What I am up to as it happens on
https://twitter.com/rebellionrider
https://www.facebook.com/imthebhardwaj
http://instagram.com/rebellionrider
https://plus.google.com/+Rebellionrider
http://in.linkedin.com/in/mannbhardwaj/
http://rebellionrider.tumblr.com/
http://www.pinterest.com/rebellionrider/
You can also Email me at
for E-mail address please check About section
Please please LIKE and SHARE my videos it makes me happy.
Thanks for liking, commenting, sharing and watching more of our videos
This is Manish from RebellionRider.com
♥ I LOVE ALL MY VIEWERS AND SUBSCRIBERS

Hi guys today we understanding about sequence in SQL language how to create and modify sequence and how these are beneficial to speedup the process of insertion.Oracle database #SqlTutorial Unbeatable,Unbreakable Platform..

This video tutorial is to understand the working of sequences in oracle SQL. The video demonstrations explain all the attributes of a create sequence statement such as start with, increment by, maxvalue, nomaxvalue, minvalue, nominvalue, cycle, nocycle, cache, nocache, order, and noorder. All the parameters are explained with appropriate examples so that the user can understand them clearly.
For more detail refer to the link:
http://plsqlnsql.blogspot.com/2017/01/sequences.html

Oracle SQL Tutorial
Oracle tutorial: How to create Id with AUTO INCREMENT in Oracle
oracle tutorial for beginners
sequence in oracle
identity key in sql
In this Oracle tutorial , we can create an auto increment field using ‘sequence’
object that can be assigned as primary keys.
Using Oracle ‘sequence’ object, you can generate new values for a column.
An Oracle sequence is an object like a table or a stored procedure.
Examples
CREATE SEQUENCE SYSTEM.MYSEQ
START WITH 1
MAXVALUE 999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER;
CREATE OR REPLACE TRIGGER TR_CITY BEFORE INSERT ON CITY FOR EACH ROW
BEGIN SELECT LPAD(LTRIM(RTRIM(TO_CHAR(myseq.NEXTVAL))),10,'0') INTO :NEW.id FROM DUAL;
END;
/
Subscribe on youtube:
https://www.youtube.com/channel/UCpiyAesWNYOXSz5GPq8lbkA
For more tutorial please visit #techquerypond
https://techquerypond.wordpress.com
https://twitter.com/techquerypond
identity column

In this video, you’ll learn how to generate random alphanumeric characters in an SQL statement in Oracle SQL
You can use Oracle SQL to generate random alphanumeric string values by using one of the built-in functions.
This function allows you to specify the type of string to generate - upper or lowercase alpha characters only, mixed alpha characters, uppercase alphanumeric characters, or any printable characters.
You can also specify the length of the string to generate, This can be a fixed number, or you can use another function to generate a random number to use for the length!
You’ll see some examples of generating random alphanumeric string values in this video.
For more information and tips on Oracle SQL, check out DatabaseStar.com:
https://www.databasestar.com/

create sequence in sql server
In this video we will discuss sequence object in SQL Server.
Sequence object
Introduced in SQL Server 2012
Generates sequence of numeric values in an ascending or descending order
Text version of the video
http://csharp-video-tutorials.blogspot.com/2015/10/sequence-object-in-sql-server-2012.html
Slides
http://csharp-video-tutorials.blogspot.com/2015/10/sequence-object-in-sql-server-2012_26.html
All SQL Server Text Articles
http://csharp-video-tutorials.blogspot.com/p/free-sql-server-video-tutorials-for.html
All SQL Server Slides
http://csharp-video-tutorials.blogspot.com/p/sql-server.html
All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd
All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatArabic/playlists
Creating the Incrementing Sequence : The following code create a Sequence object that starts with 1 and increments by 1
CREATE SEQUENCE [dbo].[SequenceObject]
AS INT
START WITH 1
INCREMENT BY 1
Generating the Next Sequence Value : Now we have a sequence object created. To generate the sequence value use NEXT VALUE FOR clause
SELECT NEXT VALUE FOR [dbo].[SequenceObject]
Output : 1
Every time you execute the above query the sequence value will be incremented by 1. I executed the above query 5 times, so the current sequence value is 5.
Retrieving the current sequence value : If you want to see what the current Sequence value before generating the next, use sys.sequences
SELECT *
FROM sys.sequences
WHERE name = 'SequenceObject'
Alter the Sequence object to reset the sequence value :
ALTER SEQUENCE [SequenceObject]
RESTART WITH 1
Select the next sequence value to make sure the value starts from 1
SELECT NEXT VALUE FOR [dbo].[SequenceObject]
Using sequence value in an INSERT query :
CREATE TABLE Employees
(
Id INT PRIMARY KEY,
Name NVARCHAR(50),
Gender NVARCHAR(10)
)
-- Generate and insert Sequence values
INSERT INTO Employees VALUES (NEXT VALUE for [dbo].[SequenceObject], 'Ben', 'Male')
INSERT INTO Employees VALUES (NEXT VALUE for [dbo].[SequenceObject], 'Sara', 'Female')
-- Select the data from the table
SELECT * FROM Employees
Creating the decrementing Sequence : The following code create a Sequence object that starts with 100 and decrements by 1
CREATE SEQUENCE [dbo].[SequenceObject]
AS INT
START WITH 100
INCREMENT BY -1
Specifying MIN and MAX values for the sequence : Use the MINVALUE and MAXVALUE arguments to specify the MIN and MAX values respectively.
Step 1 : Create the Sequence object
CREATE SEQUENCE [dbo].[SequenceObject]
START WITH 100
INCREMENT BY 10
MINVALUE 100
MAXVALUE 150
Step 2 : Retrieve the next sequence value. The sequence value starts at 100. Every time we call NEXT VALUE, the value will be incremented by 10.
SELECT NEXT VALUE FOR [dbo].[SequenceObject]
If you call NEXT VALUE, when the value reaches 150 (MAXVALUE), you will get the following error
The sequence object 'SequenceObject' has reached its minimum or maximum value. Restart the sequence object to allow new values to be generated.
Recycling Sequence values : When the sequence object has reached it's maximum value, and if you want to restart from the minimum value, set CYCLE option
ALTER SEQUENCE [dbo].[SequenceObject]
INCREMENT BY 10
MINVALUE 100
MAXVALUE 150
CYCLE
At this point, whe the sequence object has reached it's maximum value, and if you ask for the NEXT VALUE, sequence object starts from the minimum value again which in this case is 100.
To improve performance, the Sequence object values can be cached using the CACHE option. When the values are cached they are read from the memory instead of from the disk, which improves the performance. When the cache option is specified you can also specify the size of th cache , that is the number of values to cache.
The following example, creates the sequence object with 10 values cached. When the 11th value is requested, the next 10 values will be cached again.
CREATE SEQUENCE [dbo].[SequenceObject]
START WITH 1
INCREMENT BY 1
CACHE 10
Using SQL Server Graphical User Interface (GUI) to create the sequence object :
1. Expand the database folder
2. Expand Programmability folder
3. Right click on Sequences folder
4. Select New Sequence
Next video : Difference between SEQUENCE and IDENTITY in SQL Server

Watch and learn concepts of SQL Index In Oracle Database. In this tutorial you will learn about B-Tree Index and Function based Index.
------------------------------------------------------------------------
►►►LINKS◄◄◄
Blog :
Previous Tutorial
►
-------------------------------------------------------------------------
►►►Help Me In Getting A Job◄◄◄
►Help Me In Getting A Good Job By Connecting With Me on My LinkedIn and Endorsing My Skills. All My Contact Info is Down Below. You Can Also Refer Me To Your Company
Thanks
-------------------------------------------------------------------------
Copy Cloud referral link || Use this link to join copy cloud and get 20GB of free storage
https://copy.com?r=kb4rc1
--------------------------------------------------------------------------
►Make sure you SUBSCRIBE and be the 1st one to see my videos!
--------------------------------------------------------------------------
Amazon Wishlist: http://bit.ly/wishlist-amazon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
►►►Find me on Social Media◄◄◄
Follow What I am up to as it happens on
https://twitter.com/rebellionrider
https://www.facebook.com/imthebhardwaj
http://instagram.com/rebellionrider
https://plus.google.com/+Rebellionrider
http://in.linkedin.com/in/mannbhardwaj/
http://rebellionrider.tumblr.com/
http://www.pinterest.com/rebellionrider/
You can also Email me at
for E-mail address please check About section
Please please LIKE and SHARE my videos it makes me happy.
Thanks for liking, commenting, sharing and watching more of our videos
This is Manish from RebellionRider.com
♥ I LOVE ALL MY VIEWERS AND SUBSCRIBERS

Create a new Oracle SQL database using SQL. After the database is created, I demonstrate using an Oracle SQL sequence and trigger to create auto-incrementing integers which are used as the table's primary key.

A new series using APEX 18.1 is now available.
https://youtu.be/acnRWpRSrbI
This video in the APEX 5 tutorial series shows how to use SQL Scripts (part of SQL Workshop) to run scripts that create tables, sequences (to generate unique values for primary keys), triggers and insert data (INSERT INTO statements).
SQL scripts for this series are available to download at:
http://db.kreie.net

This is latest video of Learn from game, And here we have described whole process of creating sequence on Oracle database
If you like this video please like share comments and Subscribe
Here this is our official fan page : https://www.facebook.com/learnfromgame/
Our official Youtube Channel : https://www.youtube.com/channel/UCuLS...
Gyz you can mail us your request we will try our best for support you
Thank you So Much be with us !

USING SQL COMMAND
Types of SQL Commands
The following sections discuss the basic categories of commands used in SQL to perform various functions. These functions include building database objects, manipulating objects, populating database tables with data, updating existing data in tables, deleting data, performing database queries, controlling database access, and overall database administration.
The main categories are
DDL (Data Definition Language)
DML (Data Manipulation Language)
DQL (Data Query Language)
DCL (Data Control Language)
Data administration commands
Transactional control commands
Defining Database Structures
Data Definition Language, DDL, is the part of SQL that allows a database user to create and restructure database objects, such as the creation or the deletion of a table.
Some of the most fundamental DDL commands discussed during following hours include the following:
CREATE TABLE
ALTER TABLE
DROP TABLE
CREATE INDEX
ALTER INDEX
DROP INDEX
CREATE VIEW
DROP VIEW
Manipulating Data
Data Manipulation Language, DML, is the part of SQL used to manipulate data within objects of a relational database.
There are three basic DML commands:
INSERT
UPDATE
DELETE
Selecting Data
Though comprised of only one command, Data Query Language (DQL) is the most concentrated focus of SQL for modern relational database users. The base command is as follows:
SELECT
This command, accompanied by many options and clauses, is used to compose queries against a relational database. Queries, from simple to complex, from vague to specific, can be easily created. The SELECT command is discussed in exhilarating detail during Hours 7 through 16.
A query is an inquiry to the database for information. A query is usually issued to the database through an application interface or via a command line prompt.
Data Control Language
Data control commands in SQL allow you to control access to data within the database. These DCL commands are normally used to create objects related to user access and also control the distribution of privileges among users. Some data control commands are as follows:
ALTER PASSWORD
GRANT
REVOKE
CREATE SYNONYM
You will find that these commands are often grouped with other commands and may appear in a number of different lessons throughout this book.
Data Administration Commands
Data administration commands allow the user to perform audits and perform analyses on operations within the database. They can also be used to help analyze system performance. Two general data administration commands are as follows:
START AUDIT
STOP AUDIT
Do not get data administration confused with database administration. Database administration is the overall administration of a database, which envelops the use of all levels of commands. Database administration is much more specific to each SQL implementation than are those core commands of the SQL language.
Transactional Control Commands
In addition to the previously introduced categories of commands, there are commands that allow the user to manage database transactions.
COMMIT Saves database transactions
ROLLBACK Undoes database transactions
SAVEPOINT Creates points within groups of transactions in which to ROLLBACK
SET TRANSACTION Places a name on a transaction
Transactional commands are discussed extensively during Hour 6, "Managing Database Transactions."
sql interview questions,sql interview questions and answers,interview questions for freshers,SQL,sql tutorial BEGINNERS,oracle,pl sql,pl/sql,mysql,oracle interview,google interview question,trigger in oracle,dbms,rdbms, oracle tutorial,pl sql basics,pl sql tutorials, pl sql example,sql,sql server ,query,sql query,questions,interview questions,coding interview,sql coding, code , database interview questions and answers,interview questions sql, interview questions,sql server,sql interview,interview sql,interview question sql join ,inner join, group by,select sql,interview questions ,sql basic,
PL SQL Programs,PL SQL,PL SQL block,PL SQL Function,PL SQL Package,PL SQL Package body,PL SQL Procedure
,PL SQL Trigger,PL SQLType,PL SQL Type body,CREATE OR REPLACE PROCEDURE,database interview questions and answers,interview questions sql, interview questions,sql server,Procedural Language,interview sql,interview question sql join ,inner join, group by,select sql,interview questions ,sql basic,pl sql variable,oraclecoach,claire rajan,
PL SQL,PL SQL block,PL SQL Function,PL SQL Package,PL SQL Package body,PL SQL Procedure,PL SQL Trigger,PL SQLType,PL SQL

In this video we are going to be creating foreign keys. I highly recommend watching the previous video before you watch this one.
Essentially, we are creating a very simple database for a system where we can create projects and add people to those projects.
We started with the users table:
--Delete the table if needed:
--DROP TABLE users;
CREATE TABLE users(
user_id NUMBER,
username VARCHAR2(50 CHAR) UNIQUE,
CONSTRAINT users_pk PRIMARY KEY (user_id)
);
Now we are going to create a table for projects with a column that is a foreign key to the username. We're going to want to make this match data types:
CREATE TABLE projects(
project_id NUMBER,
project_name VARCHAR2(50 CHAR) UNIQUE,
creator VARCHAR2(50 CHAR)
)
Next, we need to add the column attributes we decided on last video:
CREATE TABLE projects(
project_id NUMBER,
project_name VARCHAR2(50 CHAR) UNIQUE,
creator VARCHAR2(50 CHAR) NOT NULL
)
NOT NULL because we want every project to have a creator, but we are not labeling UNIQUE because that means we could only have a specific username once in the table. We want to allow a user to create multiple projects.
We also need to add a primary key:
CREATE TABLE projects(
project_id NUMBER,
project_name VARCHAR2(50 CHAR) UNIQUE,
creator VARCHAR2(50 CHAR) NOT NULL,
CONSTRAINT projects_pk PRIMARY KEY (username)
)
Now, the question that remains is, how can I tell Oracle that I want the username to reference the username column of the other table? We have to make a foreign key constraint. As you've learned from the previous videos, there are about three ways to create constraints. You can do it inline at the column level, unnamed. You can do it at the column level, named, and you can do it at the Table level, named. Usually the table-level is preferred, but I will quickly remind you how to do all three again.
CREATE TABLE projects(
project_id NUMBER,
project_name VARCHAR2(50 CHAR) UNIQUE,
creator VARCHAR2(50 CHAR) NOT NULL REFERENCES users (username),
CONSTRAINT projects_pk PRIMARY KEY (project_id)
)
This works, but if we want to name it, we should do this:
CREATE TABLE projects(
project_id NUMBER,
project_name VARCHAR2(50 CHAR) UNIQUE,
creator VARCHAR2(50 CHAR) NOT NULL CONSTRAINT projects_users_fk REFERENCES users (username),
CONSTRAINT projects_pk PRIMARY KEY (project_id)
)
This works, but the preferred method is to do it at the table level:
CREATE TABLE projects(
project_id NUMBER,
project_name VARCHAR2(50 CHAR) UNIQUE,
creator VARCHAR2(50 CHAR) NOT NULL,
CONSTRAINT projects_pk PRIMARY KEY (project_id),
CONSTRAINT projects_users_fk FOREIGN KEY (creator) REFERENCES users (username)
)
Great! So you've learned how to create a foreign key, now we can see it inside of Oracle SQL Developer.
One important thing when it comes to foreign keys is what happens when have data in your database and you try to delete the parent row that a row in the child table references? In the next video we are going to configure that using ON DELETE. See you all then and if you enjoy this series, please do me a huge favor by liking the video and subscribing to my YouTube channel.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HELP ME! http://www.patreon.com/calebcurry
Subscribe to my newsletter: http://bit.ly/JoinCCNewsletter
Donate!: http://bit.ly/DonateCTVM2.
~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~
More content: http://CalebCurry.com
Facebook: http://www.facebook.com/CalebTheVideoMaker
Google+: https://plus.google.com/+CalebTheVideoMaker2
Twitter: http://twitter.com/calebCurry
Amazing Web Hosting - http://bit.ly/ccbluehost (The best web hosting for a cheap price!)

CREATE TABLE command in sql/oracle,INSERT command in sql/oracle
UPDATE,ALTER PASSWORD command in sql,
GRANT command,
REVOKE command i,
CREATE SYNONYM command in sql/oracle,
DELETE command in sql/oracle,
ALTER TABLE command in sql/oracle,
DROP TABLE command in sql/oracle,
CREATE INDEX command in sql/oracle,
ALTER INDEX command in sql/oracle,
DROP INDEX command in sql/oracle,
CREATE VIEW command in sql/oracle,
DROP VIEW command in sql/oracle,
Types of SQL Commands
The following sections discuss the basic categories of commands used in SQL to perform various functions. These functions include building database objects, manipulating objects, populating database tables with data, updating existing data in tables, deleting data, performing database queries, controlling database access, and overall database administration.
The main categories are
DDL (Data Definition Language)
DML (Data Manipulation Language)
DQL (Data Query Language)
DCL (Data Control Language)
Data administration commands
Transactional control commands
Defining Database Structures
Data Definition Language, DDL, is the part of SQL that allows a database user to create and restructure database objects, such as the creation or the deletion of a table.
Some of the most fundamental DDL commands discussed during following hours include the following:
CREATE TABLE
ALTER TABLE
DROP TABLE
CREATE INDEX
ALTER INDEX
DROP INDEX
CREATE VIEW
DROP VIEW
These commands are discussed in detail during Hour 3, "Managing Database Objects," Hour 17, "Improving Database Performance," and Hour 20, "Creating and Using Views and Synonyms."
Manipulating Data
Data Manipulation Language, DML, is the part of SQL used to manipulate data within objects of a relational database.
There are three basic DML commands:
INSERT
UPDATE
DELETE
These commands are discussed in detail during Hour 5, "Manipulating Data."
Selecting Data
Though comprised of only one command, Data Query Language (DQL) is the most concentrated focus of SQL for modern relational database users. The base command is as follows:
SELECT
This command, accompanied by many options and clauses, is used to compose queries against a relational database. Queries, from simple to complex, from vague to specific, can be easily created. The SELECT command is discussed in exhilarating detail during Hours 7 through 16.
A query is an inquiry to the database for information. A query is usually issued to the database through an application interface or via a command line prompt.
Data Control Language
Data control commands in SQL allow you to control access to data within the database. These DCL commands are normally used to create objects related to user access and also control the distribution of privileges among users. Some data control commands are as follows:
ALTER PASSWORD
GRANT
REVOKE
CREATE SYNONYM
You will find that these commands are often grouped with other commands and may appear in a number of different lessons throughout this book.
Data Administration Commands
Data administration commands allow the user to perform audits and perform analyses on operations within the database. They can also be used to help analyze system performance. Two general data administration commands are as follows:
START AUDIT
STOP AUDIT
Do not get data administration confused with database administration. Database administration is the overall administration of a database, which envelops the use of all levels of commands. Database administration is much more specific to each SQL implementation than are those core commands of the SQL language.
Transactional Control Commands
In addition to the previously introduced categories of commands, there are commands that allow the user to manage database transactions.
COMMIT Saves database transactions
ROLLBACK Undoes database transactions
SAVEPOINT Creates points within groups of transactions in which to ROLLBACK
SET TRANSACTION Places a name on a transaction
Transactional commands are discussed extensively during Hour 6, "Managing Database Transactions."

SQL View in Oracle Database. In this tutorial you will learn how to create a vie as well as how to replace a view along with the examples of all the DML e.g. DESCRIBE, SELECT, UPDATE, INSERT and Delete on view by Manish Sharma RebellionRider
------------------------------------------------------------------------
►►►LINKS◄◄◄
Blog : http://bit.ly/sql-view-in-oracle-database
Previous Tutorial
► Tut 5: SELECT statement http://youtu.be/f_mVBVgnqmM
-------------------------------------------------------------------------
►►►Help Me In Getting A Job◄◄◄
►Help Me In Getting A Good Job By Connecting With Me on My LinkedIn and Endorsing My Skills. All My Contact Info is Down Below. You Can Also Refer Me To Your Company
Thanks
-------------------------------------------------------------------------
Copy Cloud referral link || Use this link to join copy cloud and get 20GB of free storage
https://copy.com?r=kb4rc1
--------------------------------------------------------------------------
►Make sure you SUBSCRIBE and be the 1st one to see my videos!
--------------------------------------------------------------------------
Amazon Wishlist: http://bit.ly/wishlist-amazon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
►►►Find me on Social Media◄◄◄
Follow What I am up to as it happens on
https://twitter.com/rebellionrider
https://www.facebook.com/imthebhardwaj
http://instagram.com/rebellionrider
https://plus.google.com/+Rebellionrider
http://in.linkedin.com/in/mannbhardwaj/
http://rebellionrider.tumblr.com/
http://www.pinterest.com/rebellionrider/
You can also Email me at
[email protected]
Please please LIKE and SHARE my videos it makes me happy.
Thanks for liking, commenting, sharing and watching more of our videos
This is Manish from RebellionRider.com
♥ I LOVE ALL MY VIEWERS AND SUBSCRIBERS

This video shows the performacne improvements associated with session sequences in Oracle 12c. For more information see:
https://oracle-base.com/articles/12c/session-sequences-12cr1
Website: https://oracle-base.com
Blog: https://oracle-base.com/blog
Twitter: https://twitter.com/oraclebase
Cameo by Peter Scott
Blog: https://dwpetetechnical.wordpress.com/
Twitter: https://twitter.com/dw_pete
Cameo appearances are for fun, not an endorsement of the content of this video.

So far, we have this table declaration:
CREATE TABLE users(
user_id NUMBER,
username VARCHAR(50 CHAR)
first_name VARCHAR2(50 CHAR),
last_name VARCHAR2(50 CHAR)
)
We can run this command see that it works. As we are learning though, we are going to want to be able to recreate our table with different settings and such, but if you try to run this command, it will complain that the table already exists. So we first need to delete this table before we start editing settings. When we get more experienced, we will learn about ways to edit the structure of a table that already exists.
To fix this, we can get rid of the table using the DROP TABLE command:
DROP TABLE users
You can run this every time if you need to practice by adding a semicolon after it. This is how you can tell Oracle that you are putting in another command after it. This is known as a delimiter. When you run the script, it is going to run both commands.
Now we can go through and reconsider our table structure. This is fine for starting out because we don't have any important data in our database, but once your database is in production you are not going to want to just drop tables.
In the last video we discussed different constraints that you can apply to columns in a database table, but how do you actually apply these when you are creating a table? The first way you define constraints is to put them right after the column in your CREATE TABLE statement.
CREATE TABLE users(
username VARCHAR2(50 CHAR) NOT NULL
)
When we define constraints this way, we usually say we are adding column attributes. If you have two constraints you want to add, you just put one after the other with spaces in between. There is no particular order that is required.
CREATE TABLE users(
username VARCHAR2(50 CHAR) NOT NULL UNIQUE
)
In this situation we have already given the column the NOT NULL and UNIQUE attributes, so we should consider making this a primary key:
CREATE TABLE users(
username VARCHAR2(50 CHAR) PRIMARY KEY
)
As you can see, adding column attributes is super easy.
We can add a default like this:
CREATE TABLE users(
username VARCHAR2(50 CHAR) PRIMARY KEY,
account_balance NUMBER DEFAULT 0
)
Note that now we need the comma after the first row.
There are a few constraints we did not talk go through an example, specifically foreign keys and check constraints. We will be adding these constraints to our database in future videos. In the mean time, I have a thought for you… Many people prefer to name their column constraints. That way, we can refer to certain constraints by name. For example, we might have a primary key constraint that could be named users_pk. The way we are creating these constraints does not allow for this feature, so in the next video we are going to be discussing different ways to create constraints.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support me on Patreon! http://www.patreon.com/calebcurry
Subscribe to my newsletter: http://bit.ly/JoinCCNewsletter
Donate!: http://bit.ly/DonateCTVM2.
~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~
More content: http://CalebCurry.com
Facebook: http://www.facebook.com/CalebTheVideoMaker
Google+: https://plus.google.com/+CalebTheVideoMaker2
Twitter: http://twitter.com/calebCurry
Amazing Web Hosting - http://bit.ly/ccbluehost (The best web hosting for a cheap price!)

The audio and video now synced.
Ever tried creating a table inside a PL SQL block, or a function or a procedure? If yes, then you would know that it would raise an error, as DDL statements are not allowed inside a PL/SQL Block. So the solution to such a case, where you want to generate tables, or sequences or want to execute any DDL statement on the fly, then use synamic sql. Dynamic SQL statment will allow you to create state statements on the fly and then you can execute them using the execute immediate statement. This video tutorial demonstrates on this topic of using synamic sql with execute immediate in a PL/SQL block.