SQLite is a database engine. It does not require any server to process queries. It is a kind of software library that develops embedded software for television, smartphones, and so on. It can be used as a temporary dataset to get some data within the application due to its efficient nature. It is preferable for small datasets.
SQLite CREATE TABLE
SQLite CREATE TABLE is used to create a TABLE in a database. CREATE TABLE helps to create a table in the database with the name of the table and some columns defined in it with constraints, which stores some information. In SQLite, two tables can't be of the same name.
Syntax:
CREATE TABLE table_name
(column1 datatype KEY Constraints,
column2 datatype,
column3 datatype
.
.
.
columnN datatype)
Example 1:
Let's understand with the help of examples.
Query:
CREATE TABLE GeeksForGeeks
(emp_id varchar(255) PRIMARY KEY,
emp_name varchar(255),
dept varchar(255),
duration varchar(255))
Create GeeksForGeeks TableExplanation:
- In the above query, We have created a table called GeeksForGeeks with the help of CREATE TABLE , which contains the employee_id, employee name, department name, and duration of work.
- Here we also have used PRIMARY KEY Constraints. PRIMARY KEY ensures that every entry of data in the table is unique. that's why we implemented this onto employee_id because every employee has a unique ID in the organization.
Example 2:
Let's insert 2 records and check whether the table is created or not. If the table shows some information, it means our table is created and data is inserted into it otherwise it gives an error.
Query 1
INSERT INTO GeeksForGeeks VALUES(01,' Vipul', 'Content', '8 months');
INSERT INTO GeeksForGeeks VALUES(02, 'Deepesh', 'Mentor', '16 months');
Query 2
SELECT * FROM GeeksForGeeks
After performing INSERT Operation GeeksForGeeks Table Look Like
Explanation:
Since our table has been created that's why the above two INSERT Queries will execute and store the records in it. You can insert any number of records into the table after Creating it and perform any operation once the table has been created.
Conclusion
SQLite is a nimble and serverless database engine ideal for embedded systems and mobile applications. The CREATE TABLE statement allows for easy table creation, as demonstrated with the example of a table named "GeeksForGeeks." The use of PRIMARY KEY ensures unique employee IDs in the table.
Similar Reads
SQL Interview Questions Are you preparing for a SQL interview? SQL is a standard database language used for accessing and manipulating data in databases. It stands for Structured Query Language and was developed by IBM in the 1970's, SQL allows us to create, read, update, and delete data with simple yet effective commands.
15+ min read
SQL Tutorial SQL is a Structured query language used to access and manipulate data in databases. SQL stands for Structured Query Language. We can create, update, delete, and retrieve data in databases like MySQL, Oracle, PostgreSQL, etc. Overall, SQL is a query language that communicates with databases.In this S
11 min read
SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e
7 min read
SQL Joins (Inner, Left, Right and Full Join) SQL joins are fundamental tools for combining data from multiple tables in relational databases. Joins allow efficient data retrieval, which is essential for generating meaningful observations and solving complex business queries. Understanding SQL join types, such as INNER JOIN, LEFT JOIN, RIGHT JO
6 min read
Normal Forms in DBMS In the world of database management, Normal Forms are important for ensuring that data is structured logically, reducing redundancy, and maintaining data integrity. When working with databases, especially relational databases, it is critical to follow normalization techniques that help to eliminate
7 min read
ACID Properties in DBMS In the world of DBMS, transactions are fundamental operations that allow us to modify and retrieve data. However, to ensure the integrity of a database, it is important that these transactions are executed in a way that maintains consistency, correctness, and reliability. This is where the ACID prop
8 min read
Introduction of DBMS (Database Management System) A Database Management System (DBMS) is a software solution designed to efficiently manage, organize, and retrieve data in a structured manner. It serves as a critical component in modern computing, enabling organizations to store, manipulate, and secure their data effectively. From small application
8 min read
SQL Query Interview Questions SQL or Structured Query Language, is the standard language for managing and manipulating relational databases such as MySQL, Oracle, and PostgreSQL. It serves as a powerful tool for efficiently handling data whether retrieving specific data points, performing complex analysis, or modifying database
15 min read
CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi
6 min read
Window Functions in SQL SQL window functions are essential for advanced data analysis and database management. They enable calculations across a specific set of rows, known as a "window," while retaining the individual rows in the dataset. Unlike traditional aggregate functions that summarize data for the entire group, win
7 min read