SQL Homework – August 2017 – Create a table


August 2, 2017 by Kenneth Fisher

If you didn’t see it last month I’ve started doing monthly SQL Homework. The first month was backups, this month it’s tables.

Here is your homework for August!

  1. Create a table with at least 3 columns.
  2. Add 5 rows to the table.
  3. Add one column to the table.
  4. Update the existing 5 rows to fill in the new column.
  5. Modify the new column to not allow NULLs.
  6. Run a query against the table, pulling the columns in reverse order.

Here is how the grading will go.
Note: If you can, and have done any/all of this recently then give yourself the points. This is about ability not necessarily doing it this time. Be sure you can do it before actually giving yourself the points though.
Note: Additional points are granted in some cases. If it says T-SQL that means you wrote the T-SQL yourself and didn’t use the GUI to generate the SQL.

  • 25 pts – Create the table. (+10 for T-SQL)
  • 10 pts – Add the rows to the table. (+5 if you can do it in a single command)
  • 10 pts – Add the column. (+5 for T-SQL)
  • 10 pts – Update the values of the new columns to not be null.
  • 10 pts – Change the new column to not allow NULLs. (+5 for T-SQL)
  • 10 pts – Run the query.

5 thoughts on “SQL Homework – August 2017 – Create a table

  1. gserdijn says:

    GUI? Gooey!
    Ever since modifying a table using the GUI resulted in a truncated table (SQL Sv 2000) I use scripts.

    Additional option: make the script idempotent. 🙂

  2. Thomas Vogt Poulsen says:

    Having a problem with with the last assigment, selecting rows with columns in reverse order. Is there a way to do this, without specifying the columns order yourself (like SELECT Column4, Column3, Column2, Column1)

  3. […] created tables before but how about constraints? Constraints allow a finer level of control over what data is […]

Leave a Reply to Kenneth Fisher Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 3,755 other subscribers

Follow me on Twitter

ToadWorld Pro of the Month November 2013
%d bloggers like this: