🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)

🔧 Programmierung 🕛 kürzlich 3 Min Lesezeit
0

Key in Oracle SQL

↗ Quelle (dev.to)
🗣️ Stimme:

In Oracle SQL, keys are special columns or sets of columns that help uniquely identify rows in a table and establish relationships between tables. Here are the main types of keys:




  1. Primary Key



A primary key uniquely identifies each row in a table. It must contain unique values and cannot contain NULL values. Each table can have only one primary key, which can consist of one or multiple columns (a composite primary key).



CREATE TABLE Employees (

emp_id NUMBER PRIMARY KEY,

emp_name VARCHAR2(50) NOT NULL

);



Here, emp_id is the primary key, ensuring each employee has a unique ID.




  1. Foreign Key



A foreign key is a column (or combination of columns) that creates a link between two tables by referencing a primary key in another table. It enforces referential integrity, ensuring values in the foreign key column exist in the referenced primary key column.



CREATE TABLE Departments (

dept_id NUMBER PRIMARY KEY,

dept_name VARCHAR2(50)

);



CREATE TABLE Employees (

emp_id NUMBER PRIMARY KEY,

emp_name VARCHAR2(50),

dept_id NUMBER,

FOREIGN KEY (dept_id) REFERENCES Departments(dept_id)

);



Here, dept_id in Employees is a foreign key referencing dept_id in Departments.




  1. Unique Key



A unique key constraint ensures that all values in a column (or set of columns) are unique. Unlike a primary key, a table can have multiple unique keys, and unique key columns can contain NULL values.



CREATE TABLE Employees (

emp_id NUMBER PRIMARY KEY,

emp_email VARCHAR2(100) UNIQUE

);



Here, emp_email is a unique key, ensuring no duplicate email addresses, although it allows NULL.




  1. Composite Key



A composite key is a primary or unique key made up of two or more columns. It is used when a single column isn’t enough to uniquely identify rows in a table.



CREATE TABLE ProjectAssignments (

emp_id NUMBER,

project_id NUMBER,

assignment_date DATE,

PRIMARY KEY (emp_id, project_id)

);



Here, (emp_id, project_id) together form a composite primary key, uniquely identifying each assignment.




  1. Candidate Key



A candidate key is any column or set of columns that could serve as a primary key. Each table may have multiple candidate keys, but only one can be chosen as the primary key.



For example, in an Employees table:



emp_id and emp_email could both uniquely identify rows.



You might choose emp_id as the primary key, while emp_email remains a candidate key.




  1. Alternate Key



An alternate key is any candidate key that is not chosen as the primary key.



In the example above, if emp_id is the primary key, then emp_email is considered an alternate key.




  1. Super Key



A super key is any combination of columns that can uniquely identify rows in a table. A primary key, unique key, or a combination of these can be a super key. Super keys can contain additional columns that aren’t necessary for uniqueness.



For example:



In the Employees table, emp_id is a super key.



The combination (emp_id, emp_name) is also a super key, though it contains unnecessary information (emp_name).



These keys help enforce data integrity, establish relationships between tables, and ensure that each record in a database is unique and correctly associated.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
3 Quellen
GPT-6 Astra Release Today? OpenAI’s Next Major AI Model Is Almost Here
1 Quelle
Apple accuses OpenAI of destroying evidence as trade-secrets fight intensifies
1 Quelle
Major AI platforms go down in unprecedented simultaneous outage
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Key in Oracle SQL

Thematisch verwandte Begriffe: Oracle · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...