BaşlayınÜcretsiz Başlayın

ADD key CONSTRAINTs to the tables

Two of the tables in your database already have well-suited candidate keys consisting of one column each: organizations and universities with the organization and university_shortname columns, respectively.

In this exercise, you'll rename these columns to id using the RENAME COLUMN command and then specify primary key constraints for them. This is as straightforward as adding unique constraints (see the last exercise of Chapter 2):

ALTER TABLE table_name
ADD CONSTRAINT some_name PRIMARY KEY (column_name)

Note that you can also specify more than one column in the brackets.

Bu egzersiz

Introduction to Relational Databases in SQL

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

-- Rename the organization column to id
___ ___ organizations
___ ___ organization TO ___;

-- Make id a primary key
ALTER TABLE organizations
___ ___ organization_pk ___ KEY (___);
Kodu Düzenle ve Çalıştır