CommencerCommencer gratuitement

Choosing data types at table creation

It is best to specify the data type for a column when the table is initially created. The type can be changed later. However, this change may have unintended consequences if the column contains previously populated values. In this exercise, you will specify data types based on the category of data to which the values belong.

We will now return to the Small Business Association (SBA) database example from Chapter 1. SBA loans are provided for specific business projects. You will complete the definition of the project table using the most appropriate column type.

Cet exercice fait partie du cours

Creating PostgreSQL Databases

Afficher le cours

Instructions

  • Complete the CREATE TABLE command for the project table using the correct data type from the following choices: TEXT, BOOLEAN, and NUMERIC.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

-- Create the project table
___ ___ ___ (
	-- Unique identifier for projects
	id SERIAL PRIMARY KEY,
    -- Whether or not project is franchise opportunity
	is_franchise ___ DEFAULT FALSE,
	-- Franchise name if project is franchise opportunity
    franchise_name ___ DEFAULT NULL,
    -- State where project will reside
    project_state ___,
    -- County in state where project will reside
    project_county ___,
    -- District number where project will reside
    congressional_district ___,
    -- Amount of jobs projected to be created
    jobs_supported ___
);
Modifier et exécuter le code