If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Welcome to SQL

SQL, or Structured Query Language, is a language specifically designed for accessing and interacting with databases. It allows users to create tables, modify data, and retrieve information in a fast and efficient manner. SQL is one of the most popular query languages in use today.

Want to join the conversation?

  • starky ultimate style avatar for user wbwalp
    Are there any languages that create databases besides SQL?
    (147 votes)
    Default Khan Academy avatar avatar for user
  • starky ultimate style avatar for user wbwalp
    What does SQL stand for?
    (78 votes)
    Default Khan Academy avatar avatar for user
  • hopper cool style avatar for user RobloxianIzzy {Currently online}
    Can you learn SQL when you're under 12?
    (28 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user fyfe275
    Am I too beginner for this course? I have worked with a CRM database for 4 years, mostly doing data entry, lots of queries, exporting, reporting. Our DBA is leaving and I would like to learn a few basics of her role in terms of adjusting reports and some automatic import/export functions she has set up. I've read many of the comments below and it's all completely foreign to me. I am not even sure what I will need to take this course. My co-worker said I should download SQL server express, but I haven't seen any mention of this. Will this go right over the head of someone with no experience in coding language? Thanks for your feedback!
    (5 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Emily
      fyfe275, I'm inferring that by "CRM database," you are referring to working with a "Customer Relationship Management" database. My guess is that you have likely been using a "User Interface" or the "Front End" of a database. I have seen some companies which use applications that have a relational database back-end, which has forever been left on auto-pilot. When you talk about "adjusting report" and making some "automatic import/export" functions, these could be features of the CRM application that you are using.

      While you have a chance, talk to your DBA directly. Get logins and passwords to everything she has access to. Make sure your computer has all applications installed that she utilizes. Ask her if she "manages" the "database" from the CRM application, or at the database level.

      If you are really stepping into the shoes of a full, primary DBA role and don't have experience with SQL, even though you can get a lot of free training and resources here, I would ask your company to send you to some DBA courses.

      In small to mid-size companies outside of technology industries, it is common that the breadth and depth of technology skills of individuals and collectively is not the same as walking into a company with hundreds of different roles in technology.

      Don't fret. First, find out what you actually need to do. If you are managing reports and some automated functions, your background may be well-suited to take over the "DBA"s job. It's possible that most of the job duties are CRM administration, rather than a full-fledged "DBA." The job title could be misleading.

      In your company, if everyone refers to the CRM as the "CRM database," this might be why her position is titled "DBA." I am not trying to diminish her role or yours whatsoever. I'm just saying that it's important to determine what the job duties really are.

      In some applications, the developers have more or less "locked down" access to the database, because it has been developed in a way where it doesn't need active administration.

      If the database is running on a small little stand-alone server that was initially setup by the vendor or a contractor, this should lower your blood pressure. Hopefully the CRM application and the database are not installed on the same server disk (and competing for resources), but they might be. If they are both installed on the same server and it has been working fine for the 4 years you have used it, it's possible that the database does not need a "DBA."

      A more appropriate title might be "Data Administrator," "CRM Administrator" or "CRM Data Administrator."

      Don't let the title alone fool you or scare you Find out. And if you really do need to be a full-fledged primary DBA on a database that needs daily monitoring, performance tuning, backups and more, please take an in-person, week-long class.

      You can also call the CRM vendor and ask them about their documentation, setup and the needs of the actual database. If the actual "DBA" role is low key, just having vendor support might be enough to get you through any database-specific needs. Hopefully the CRM wasn't a custom application and was an off-the-shelf package from a company still in business. If so, they will be familiar with common database problems and how to respond to them.

      I wish you well! Part of working in technology is being ready to be in over your head at some point, so you are forced to constantly be learning and expanding your skill sets and developing your expertise.
      (44 votes)
  • winston default style avatar for user RadicalRose
    Can you add SQl to programs that are HTML based
    (13 votes)
    Default Khan Academy avatar avatar for user
  • aqualine tree style avatar for user CodeLoader
    Why did KA choose to use SQLite environment and not MySQL or others?
    Also, why don't scripts accept some words like "INT" instead of "INTEGER" which are accepted in SQL language?
    (5 votes)
    Default Khan Academy avatar avatar for user
  • hopper jumping style avatar for user L G
    So it's a spreadsheet kind of thing
    (3 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user Chuck
    I know that it's possible for more malicious users to use SQL injection as a tactic to exploit vulnerabilities in webpage databases where user input is allowed. But is it possible to use SQL in a similar manner to access information about the website's data (in a wholesome, non harmful way lol) such as sorting data by ID, keywords, etc.?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • ohnoes default style avatar for user Robert Stone
      Yes, that's primarily what it's used for on web sites. Not all of a web site's data are in an SQL database necessarily, but this comment, for example, is being stored in some sort of database.

      Web sites are not going to knowingly let users just execute SQL queries though because that may still expose too much information, such as passwords. So if you're asking whether you can just query any web site using SQL, the answer is no. SQL is used by web applications to store data, but the SQL interface is not exposed to users.

      But sure, if someone found an SQL injection vulnerability they could conceivably use it just to search a forum or something. I doubt most people would be looking for such a vulnerability just so they could search public data on a web site using SQL though.
      (13 votes)
  • starky seedling style avatar for user The Last Legend
    I'm confused at why there is a such thing as noSQL, and what its point is?
    (7 votes)
    Default Khan Academy avatar avatar for user
  • female robot ada style avatar for user Hermioneg
    what does SQL stand for?
    (4 votes)
    Default Khan Academy avatar avatar for user

Video transcript

- [Instructor] The world is full of data. Every app that you use is full of data. On Khan Academy, we store data about users and badges and progress. On Facebook they store data about who you are, who your friends are, and what they're posting. On Bank of America they store data about how much money you have and what accounts that's in. How do these apps store data? Well, they use a database which is a program that helps store data and provides functionality for adding, modifying, and querying that data, and doing that all fast. Databases come in many forms, but a really popular type of database is called a relational database. It stores each kind of data in a table, which is kind of like storing data in a spreadsheet. A row represents an item, and a column represents properties about that item. For example, to store data about Khan Academy users, we'd have a users table with a row for each user and columns for properties like their nickname and location. Relational databases make it particularly easy to form relationships between tables. For example, in order to store Khan Academy users and their badges, we might have a users table and a badges table, and then a user badges table to remember which users earned which badges, just by mapping user IDs to badge IDs. That's a more efficient form of storage than having to repeat everything about the user and everything about the badge in the user badges table. Most database come with a query language to interact with the database. SQL is a language designed entirely for accessing databases and is the most popular of them. With SQL, we can create tables, change data, get back the data we're interested in. Like if we wanna find out which users joined in the last week or which users have a particular badge. That's what we're going to teach here. And you'll actually get to try out SQL here in the browser using SQL Lite, a particular implementation of it. You won't be able to write the whole app here, but when you're done learning SQL, you'll have a much better understanding of how data is stored in the apps that you use and be able to use SQL if you ever build an app.