Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Michael Stedman
seal-mask
.a{fill-rule:evenodd;}techdegree
Michael Stedman
Full Stack JavaScript Techdegree Student 13,838 Points

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
221,573 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,135 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,135 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.