SQL CREATE Database 🎯

beginner
20 min

SQL CREATE Database 🎯

Welcome to our comprehensive guide on creating a database using SQL! Whether you're a beginner or an intermediate learner, we've got you covered. Let's dive into the world of databases and learn how to create them using SQL.

What is SQL? 📝

SQL (Structured Query Language) is a standard language for managing and manipulating databases. It allows you to create, modify, and query databases and the data they contain.

Creating a Database ✅

To create a database in SQL, you use the CREATE DATABASE statement. Here's an example:

sql
CREATE DATABASE MyDatabase;

In this example, we're creating a database named MyDatabase.

Database Types 💡

SQL supports two types of databases:

  1. Relational Database: These are based on the relational model and use tables to store data. Examples include MySQL, PostgreSQL, and Oracle.
  2. Non-relational Database: These are not based on the relational model and do not use tables. Examples include MongoDB and Cassandra.

Creating a Table 🎯

Once you've created a database, you can create tables to store your data. Let's create a table called students in our MyDatabase database:

sql
USE MyDatabase; CREATE TABLE students ( id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10) );

In this example, we're using the USE statement to switch to our MyDatabase database. Then, we're creating a table called students with four columns: id, name, age, and gender. The PRIMARY KEY keyword indicates that the id column is unique for each record.

Quiz 📝

Quick Quiz
Question 1 of 1

What does the `CREATE DATABASE` statement do in SQL?

Remember, practice makes perfect! Keep exploring and experimenting with SQL to strengthen your understanding. Happy learning! 🎉

Stay tuned for our next lesson where we'll learn how to insert, retrieve, update, and delete data from our students table. 🎯