Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Database Foundations Introduction to Data, Databases and SQL Creating Tables

Statements case sensitive?

Are parts of the statement case sensitive? In the video, Andrew Chalkley shows the statement creating a table as:

CREATE TABLE actors (name VARCHAR(200))

Is the "CREATE TABLE", and the datatype "VARCHAR" required to be upper case? If its not required for the statement to work, is it good practice? Or does it not really matter as long as you try to stay consistent?

2 Answers

Steven Parker
Steven Parker
229,657 Points

Generally, SQL is not case-sensitive.

Some databases might vary on this, but it's true in the most popular ones (Oracle, MS SQL, MySQL).

Some developers adopt a practice of using one case to show reserved words and another for fields, but the choice of case may differ. I've seen editors that have helper settings that can be set either way.

I personally prefer to use uppercase for reserved words and lowercase elsewhere, just as shown in the example. I believe this is a more common choice, but there's no universal consensus.

Kevin Korte
Kevin Korte
28,148 Points

I don't know if it changes for different versions of SQL, but I believe SQL keywords are case-insensitive, however, I think it's been considered best practices to capitalize those keywords for better human readability.

However, I think that, at lease in some versions, column and table names are case sensitive, so just something to keep in mind.

Kevin Korte Can you help me? Cuz I don't understand where I'm suppose to type this code at? Do I have to download something? There's no workspace attached to this video? Sorry if this is a stupid question but I am so confuse and could use the help.

Kevin Korte
Kevin Korte
28,148 Points

It would just depend. There are a couple of SQL softwares out there, that you could run a SQL statement in, MySQL workbench is one of them: https://www.mysql.com/products/workbench/

The other is depending on your framework or structure of your website, you my actually write SQL statements in your applications code to "do stuff" on the database.