-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LiveLabs Sprint w/ LiveSQL POC (#191)
- Loading branch information
1 parent
f8a1df2
commit 40df314
Showing
3 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
data-management/sprint-sql/livesql-sprint-poc/create-tables.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# How can I create tables in the Oracle database? | ||
<button onclick = "window.location.href = 'https://livesql.oracle.com/ords/livesql/file/tutorial_CT7TS7W016WULZZL5VLY92W9K.html';" style = "background-color: #884EA2; font-size: 14px; font-style: italic; font-weight: bold; color: white; border-radius: 8px; width: 100px; height: 30px; border: 0px;">Try It Now</button></br> | ||
|
||
Duration: 2 minutes | ||
|
||
## Create table in Oracle database | ||
|
||
Tables are the basic unit of data storage in an Oracle Database. Data is stored in rows and columns. A CREATE TABLE statement creates a table. Tables contain columns and constraints, rules to which data must conform. Table-level constraints specify a column or columns. Columns have a data type and can specify column constraints (column-level constraints). | ||
|
||
``` | ||
<copy> | ||
CREATE TABLE table_name ( | ||
column1_name data_type column_constraint, | ||
column2_name data_type column_constraint, | ||
... | ||
constraint table_constraint; | ||
); | ||
</copy> | ||
``` | ||
|
||
### Example | ||
|
||
For example, you define a table with a table name, such as employees, and a set of columns. You give each column a column name, such as employee\_id, last\_name, and job\_id; a datatype, such as VARCHAR2, DATE, or NUMBER; and a width. The width can be predetermined by the datatype, as in DATE. If columns are of the NUMBER datatype, define precision and scale instead of width. A row is a collection of column information corresponding to a single record.column information corresponding to a single record. | ||
|
||
You can specify rules for each column of a table. These rules are called integrity constraints. One example is a NOT NULL integrity constraint. This constraint forces the column to contain a value in every row. | ||
|
||
``` | ||
create table DEPARTMENTS ( | ||
deptno number, | ||
name varchar2(50) not null, | ||
location varchar2(50), | ||
constraint pk_departments primary key (deptno) | ||
); | ||
``` | ||
|
||
Tables can declarative specify relationships between tables, typically referred to as referential integrity. To see how this works we can create a "child" table of the DEPARTMENTS table by including a foreign key in the EMPLOYEES table that references the DEPARTMENTS table. | ||
|
||
``` | ||
create table EMPLOYEES ( | ||
empno number, | ||
name varchar2(50) not null, | ||
job varchar2(50), | ||
manager number, | ||
hiredate date, | ||
salary number(7,2), | ||
commission number(7,2), | ||
deptno number, | ||
constraint pk_employees primary key (empno), | ||
constraint fk_employees_deptno foreign key (deptno) | ||
references DEPARTMENTS (deptno) | ||
); | ||
``` | ||
|
||
Foreign keys must reference primary keys, so to create a "child" table the "parent" table must have a primary key for the foreign key to reference. | ||
|
||
## Learn More | ||
|
||
* Explore more about [Creating Tables](https://docs.oracle.com/cd/B28359_01/server.111/b28310/tables003.htm#ADMIN11634) | ||
* [Introduction to Oracle SQL Workshop](https://livelabs.oracle.com/pls/apex/dbpm/r/livelabs/view-workshop?wid=943) | ||
* [SQL Language Reference](https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/Introduction-to-Oracle-SQL.html#GUID-049B7AE8-11E1-4110-B3E4-D117907D77AC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content="Oracle LiveLabs gives you access to Oracle's products to run a wide variety of labs and workshops; allowing you to experience our best technology, live!"> | ||
<title>Oracle LiveLabs</title> | ||
|
||
<script src="https://oracle-livelabs.github.io/common/redwood-hol/js/jquery-1.11.0.min.js"></script> | ||
<script src="https://oracle-livelabs.github.io/common/redwood-hol/js/jquery-ui-1.10.4.custom.js"></script> | ||
<script src="https://oracle-livelabs.github.io/common/redwood-hol/js/main.min.js"></script> | ||
|
||
<link rel="stylesheet" href="https://oracle-livelabs.github.io/common/redwood-hol/css/style.min.css" /> | ||
<link rel="shortcut icon" href="https://oracle-livelabs.github.io/common/redwood-hol/img/favicon.ico" /> | ||
</head> | ||
|
||
<body> | ||
<header class="hol-Header" role="banner"> | ||
<div class="hol-Header-wrap"> | ||
<div class="hol-Header-logo"><span>Oracle LiveLabs</span></div> | ||
<a href="https://livelabs.oracle.com" target="_blank" id="livelabs" title="Oracle LiveLabs"></a> | ||
<div class="hol-Header-actions"> | ||
<button id="openNav" class="hol-Header-button hol-Header-button--menu rightNav" aria-label="Open Menu" | ||
title="Open Menu"> | ||
<span class="hol-Header-toggleIcon"></span> | ||
</button> | ||
</div> | ||
</div> | ||
</header> | ||
|
||
<div id="container"> | ||
<div id="leftNav"> | ||
<div id="toc"></div> | ||
</div> | ||
<div id="contentBox"> | ||
<main class="hol-Content" id="module-content"></main> | ||
</div> | ||
</div> | ||
|
||
<footer class="hol-Footer"> | ||
<a class="hol-Footer-topLink" href="#top">Return to Top</a> | ||
<div id="footer-banner"><div class="footer-row"> | ||
<div class="footer-content"><ul class="footer-links"> | ||
<li><a href="https://docs.oracle.com/pls/topic/lookup?ctx=en/legal&id=cpyr" target="_blank" aria-label="Open a new window to Oracle legal notices" data-lbl="copyright">© Oracle</a></li> | ||
<li><a href="https://www.oracle.com/corporate/index.html" target="_blank" aria-label="Open a new window to learn more about oracle" data-lbl="about-oracle">About Oracle</a></li> | ||
<li><a href="https://www.oracle.com/corporate/contact/" target="_blank" aria-label="Open a new window to contact oracle" data-lbl="contact-us">Contact Us</a></li> | ||
<li class="footer-links-break"></li> | ||
<li><a href="https://docs.oracle.com/en/browseall.html" target="_blank" aria-label="Open a new window to products a-z" data-lbl="products-a-z">Products A-Z</a></li> | ||
<li><a href="https://www.oracle.com/legal/privacy/" target="_blank" aria-label="Open a new window to read more about Oracle terms of use and privacy" data-lbl="terms-of-use-and-privacy">Terms of Use & Privacy</a></li> | ||
<li><a href="https://www.oracle.com/legal/privacy/privacy-policy.html#11" target="_blank" aria-label="Open a new window to read more about managing Oracle cookie preferences" data-lbl="cookie-preferences">Cookie Preferences</a></li> | ||
<li><a href="https://www.oracle.com/legal/privacy/marketing-cloud-data-cloud-privacy-policy.html#adchoices" target="_blank" aria-label="Open a new window to ad choices" data-lbl="ad-choices">Ad Choices</a></li> | ||
<li class="footer-links-break"></li><li class="last"><a href="https://docs.oracle.com/pls/topic/lookup?ctx=en/legal&id=cpyr" target="_blank" aria-label="Open a new window to Oracle legal notices" data-lbl="copyright">© Oracle</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</footer> | ||
</body> | ||
|
||
</html> |
33 changes: 33 additions & 0 deletions
33
data-management/sprint-sql/livesql-sprint-poc/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"workshoptitle": "LiveLabs Sprints", | ||
"help": "livelabs-help-db_us@oracle.com", | ||
"tutorials": [ | ||
{ | ||
"title": "How can I create tables in the Oracle database?", | ||
"description": "", | ||
"filename": "./create-tables.md" | ||
}, | ||
{ | ||
"title": "How can I insert data into a table in the Oracle database?", | ||
"description": "", | ||
"filename": "../insert-data/insert-data.md" | ||
}, | ||
{ | ||
"title": "How can I query a table in the Oracle database?", | ||
"description": "", | ||
"filename": "../query-tables/query-tables.md" | ||
}, | ||
{ | ||
"title": "How can I index columns in the Oracle database?", | ||
"description": "", | ||
"filename": "../index-columns/index-columns.md" | ||
}, | ||
{ | ||
"title": "How can I create triggers for a table in the Oracle database?", | ||
"description": "", | ||
"filename": "../create-triggers/create-triggers.md" | ||
} | ||
], | ||
"task_type": "Sections", | ||
"hide_button": "true" | ||
} |