TN Online TestSamacheer Kalvi practice

Data manipulation through SQL - Formula Sheet

Share this chapter: Telegram

SQL Syntax and Query Structures

In database manipulation with SQL, syntax templates act as formulas. Below are the key statements and functions used with SQLite in Python:

1. Database Connection and Cursor Initialization

connection = sqlite3.connect(database_name)

cursor = connection.cursor()

2. Database Schema Creation

CREATE TABLE table_name (column_1 data_type constraints, column_2 data_type, ...);

3. Data Insertion Formula

INSERT INTO table_name (column_list) VALUES (value_list);

4. Aggregate Functions

Function Purpose Syntax Formula
COUNT() Returns the total count of matching rows. SELECT COUNT(column_name) FROM table_name;
AVG() Computes the average of numerical column values. SELECT AVG(column_name) FROM table_name;
SUM() Calculates the total sum of numerical column values. SELECT SUM(column_name) FROM table_name;
MAX() Finds the maximum value in a column. SELECT MAX(column_name) FROM table_name;
MIN() Finds the minimum value in a column. SELECT MIN(column_name) FROM table_name;
Solved MCQs → Practice test →

More for this chapter

Book Back Questions10 textbook MCQs · solved Additional MCQs15 extra MCQs · solved Practice TestInteractive · instant score Book Back TestTest yourself on the textbook set Additional MCQ TestTest yourself on the extra set Study NotesConcepts & methods

More chapters in Computer Science

View all
1 Function 2 Data Abstraction 3 Scoping 4 Algorithmic Strategies 5 Python Variables and Operators 6 Control Structures 7 Python Functions 8 Strings and String Manipulation 9 Lists, Tuples, Sets and Dictionary 10 Python Classes and Objects 11 Database Concepts 12 Structured Query Language (SQL) 13 Python and CSV Files 14 Importing C++ Programs in Python 16 Data Visualization using Pyplot: Line Chart, Pie Chart and Bar Chart