-- небольшой анализ посещаемости school в PostgreSQL:
-- Поле         Описание
-- event_id     идентификатор урока
-- event_date	  дата урока
-- customer_id	идентификатор ученика
-- is_attend	  1 — посетил, 0 — пропустил
-- group_ids	  идентификатор группы
-- teacher_ids	идентификатор преподавателя
-- attendance_id	идентификатор строки

-- создание таблицы:
CREATE TABLE school (
    attendance_id INT PRIMARY KEY,    -- Уникальный идентификатор строки
    event_id INT NOT NULL,            -- Идентификатор урока
    event_date DATE NOT NULL,         -- Дата урока
    customer_id INT NOT NULL,         -- Идентификатор ученика
    is_attend INT NOT NULL,           -- 1 — посетил, 0 — пропустил
    group_ids INT,                    -- Идентификатор группы (NULL, если группа не указана)
    teacher_ids INT                   -- Идентификатор преподавателя (NULL, если преподаватель не указан)
);

-- создание индексов:
CREATE INDEX idx_event_id ON school(event_id);
CREATE INDEX idx_customer_id ON school(customer_id);

-- импорт данных для анализа:
INSERT INTO 
  school (attendance_id, 
          event_id, 
          event_date, 
          customer_id, 
          is_attend, 
          group_ids, 
          teacher_ids)
VALUES
(12, 5, '2020-05-22', 47, 1, 2, 6),
(57, 15, '2020-06-03', 354, 1, 5, 4),
(158, 34, '2020-06-17', 183, 1, 5, 4),
(95, 22, '2020-06-11', 12, 1, 1, 3),
(185, 36, '2020-06-19', 260, 1, 5, 4),
(5, 3, '2020-05-21', 197, 1, 1, 3),
(165, 30, '2020-06-18', 419, 1, 3, 5),
(24, 8, '2020-05-26', 47, 1, 2, 6),
(108, 25, '2020-06-10', 401, 1, 5, 4),
(159, 34, '2020-06-17', 354, 1, 5, 4),
(288, 59, '2020-07-08', 700, 1, 5, 4),
(210, 43, '2020-06-25', 587, 0, 3, 5),
(11, 5, '2020-05-22', 137, 1, 2, 6),
(207, 43, '2020-06-25', 52, 1, 3, 5),
(211, 44, '2020-06-25', 595, 0, 1, 3),
(87, 20, '2020-06-06', 249, 1, 1, 3),
(328, 58, '2020-07-15', 654, 1, 5, 4),
(49, 14, '2020-06-02', 308, 1, 2, 6),
(167, 35, '2020-06-17', 593, 1, 1, 3),
(239, 50, '2020-07-01', 137, 1, 2, 7),
(249, 52, '2020-07-01', 700, 1, 5, 4),
(258, 53, '2020-07-02', 452, 1, 3, 5),
(56, 15, '2020-06-03', 183, 1, 5, 4),
(83, 19, '2020-06-05', 258, 1, 5, 4),
(21, 8, '2020-05-26', 192, 1, 2, 6),
(218, 45, '2020-06-26', 192, 1, 2, 6),
(68, 16, '2020-06-04', 345, 1, 1, 3),
(255, 49, '2020-06-30', 247, 0, 1, 3),
(55, 15, '2020-06-03', 295, 1, 5, 4),
(271, 55, '2020-07-03', 360, 1, 5, 4),
(9, 5, '2020-05-22', 192, 1, 2, 6),
(252, 52, '2020-07-01', 260, 0, 5, 4),
(281, 57, '2020-07-07', 590, 1, 1, 3),
(127, 27, '2020-06-12', 258, 0, 5, 4),
(102, 24, '2020-06-10', 435, 1, 2, 6),
(29, 10, '2020-05-27', 135, 1, 5, 4),
(171, 35, '2020-06-17', 247, 0, 1, 3),
(320, 67, '2020-07-16', 419, 0, 3, 5),
(266, 46, '2020-07-03', 99, 1, 2, 7),
(305, 62, '2020-07-09', 593, 1, 1, 3),
(148, 33, '2020-06-17', 137, 1, 2, 6),
(17, 7, '2020-05-25', 30, 0, 3, 5),
(89, 21, '2020-06-09', 383, 1, 3, 5),
(112, 25, '2020-06-10', 260, 1, 5, 4),
(284, 59, '2020-07-08', 234, 1, 5, 4),
(151, 33, '2020-06-17', 99, 1, 2, 6),
(34, 11, '2020-05-29', 135, 1, 5, 4),
(169, 35, '2020-06-17', 249, 0, 1, 3),
(329, 58, '2020-07-15', 354, 1, 5, 4),
(135, 28, '2020-06-16', 452, 1, 3, 5),
(259, 53, '2020-07-02', 419, 1, 3, 5),
(173, 37, '2020-06-19', 137, 1, 2, 6),
(198, 41, '2020-06-24', 586, 1, 2, 6),
(250, 52, '2020-07-01', 183, 1, 5, 4),
(279, 56, '2020-07-07', 419, 1, 3, 5),
(38, 11, '2020-05-29', 258, 0, 5, 4),
(22, 8, '2020-05-26', 152, 1, 2, 6),
(161, 30, '2020-06-18', 14, 0, 3, 5),
(247, 52, '2020-07-01', 401, 1, 5, 4),
(131, 29, '2020-06-13', 12, 1, 1, 3),
(178, 36, '2020-06-19', 493, 1, 5, 4),
(64, 17, '2020-06-04', 137, 1, 2, 5),
(295, 61, '2020-07-10', 725, 1, 5, 4),
(306, 63, '2020-07-09', 52, 1, 3, 5),
(245, 52, '2020-07-01', 493, 1, 5, 4),
(61, 17, '2020-06-04', 192, 0, 2, 5),
(104, 24, '2020-06-10', 137, 0, 2, 6),
(321, 58, '2020-07-15', 725, 0, 5, 4),
(262, 54, '2020-07-02', 593, 1, 1, 3),
(54, 15, '2020-06-03', 335, 1, 5, 4),
(287, 59, '2020-07-08', 401, 1, 5, 4),
(60, 15, '2020-06-03', 258, 0, 5, 4),
(80, 19, '2020-06-05', 354, 1, 5, 4),
(155, 34, '2020-06-17', 335, 1, 5, 4),
(301, 61, '2020-07-10', 183, 0, 5, 4),
(39, 12, '2020-05-30', 145, 1, 1, 3),
(65, 17, '2020-06-04', 99, 1, 2, 5),
(270, 55, '2020-07-03', 493, 1, 5, 4),
(58, 15, '2020-06-03', 49, 1, 5, 4),
(82, 19, '2020-06-05', 260, 1, 5, 4),
(32, 10, '2020-05-27', 36, 0, 5, 4),
(3, 4, '2020-05-21', 26, 1, 3, 5),
(123, 27, '2020-06-12', 183, 1, 5, 4),
(154, 34, '2020-06-17', 360, 1, 5, 4),
(273, 55, '2020-07-03', 681, 0, 5, 4),
(219, 45, '2020-06-26', 586, 1, 2, 6),
(78, 19, '2020-06-05', 335, 1, 5, 4),
(225, 47, '2020-06-26', 401, 1, 5, 4),
(19, 7, '2020-05-25', 26, 1, 3, 5),
(4, 4, '2020-05-21', 37, 1, 3, 5),
(2, 4, '2020-05-21', 52, 1, 3, 5),
(69, 16, '2020-06-04', 249, 1, 1, 3),
(299, 61, '2020-07-10', 401, 1, 5, 4),
(188, 38, '2020-06-20', 580, 0, 1, 3),
(323, 58, '2020-07-15', 26, 1, 5, 4),
(228, 47, '2020-06-26', 260, 1, 5, 4),
(254, 49, '2020-06-30', 593, 1, 1, 3),
(6, 3, '2020-05-21', 94, 1, 1, 3),
(72, 18, '2020-06-05', 279, 1, 3, 6),
(103, 24, '2020-06-10', 379, 1, 2, 6),
(47, 13, '2020-06-01', 37, 1, 3, 5),
(129, 29, '2020-06-13', 42, 1, 1, 3),
(290, 59, '2020-07-08', 354, 1, 5, 4),
(125, 27, '2020-06-12', 49, 1, 5, 4),
(179, 36, '2020-06-19', 360, 1, 5, 4),
(227, 47, '2020-06-26', 354, 1, 5, 4),
(257, 53, '2020-07-02', 52, 1, 3, 5),
(315, 64, '2020-07-15', 192, 1, 2, 6),
(317, 64, '2020-07-15', 379, 1, 2, 6),
(269, 55, '2020-07-03', 26, 1, 5, 4),
(213, 44, '2020-06-25', 593, 1, 1, 3),
(92, 21, '2020-06-09', 419, 1, 3, 5),
(243, 52, '2020-07-01', 234, 1, 5, 4),
(214, 44, '2020-06-25', 580, 0, 1, 3),
(230, 48, '2020-06-27', 590, 1, 1, 3),
(184, 36, '2020-06-19', 354, 1, 5, 4),
(189, 38, '2020-06-20', 247, 0, 1, 3),
(74, 18, '2020-06-05', 26, 1, 3, 6),
(222, 47, '2020-06-26', 26, 0, 5, 4),
(278, 56, '2020-07-07', 452, 1, 3, 5),
(14, 6, '2020-05-23', 94, 1, 1, 3),
(300, 61, '2020-07-10', 700, 1, 5, 4),
(286, 59, '2020-07-08', 493, 1, 5, 4),
(81, 19, '2020-06-05', 49, 1, 5, 4),
(238, 51, '2020-06-30', 587, 0, 3, 5),
(177, 37, '2020-06-19', 379, 0, 2, 6),
(224, 47, '2020-06-26', 360, 1, 5, 4),
(296, 61, '2020-07-10', 234, 0, 5, 4),
(244, 52, '2020-07-01', 26, 1, 5, 4),
(45, 13, '2020-06-01', 52, 1, 3, 5),
(325, 58, '2020-07-15', 401, 1, 5, 4),
(26, 9, '2020-05-28', 247, 1, 1, 3),
(149, 33, '2020-06-17', 192, 0, 2, 6),
(308, 63, '2020-07-09', 419, 1, 3, 5),
(293, 60, '2020-07-10', 99, 1, 2, 7),
(106, 25, '2020-06-10', 360, 1, 5, 4),
(105, 24, '2020-06-10', 99, 1, 2, 6),
(234, 48, '2020-06-27', 12, 1, 1, 3),
(216, 44, '2020-06-25', 12, 1, 1, 3),
(75, 18, '2020-06-05', 37, 1, 3, 6),
(96, 23, '2020-06-11', 383, 1, 3, 5),
(128, 29, '2020-06-13', 249, 0, 1, 3),
(220, 45, '2020-06-26', 99, 1, 2, 6),
(192, 40, '2020-06-23', 52, 1, 3, 5),
(193, 40, '2020-06-23', 452, 1, 3, 5),
(36, 11, '2020-05-29', 260, 1, 5, 4),
(202, 42, '2020-06-24', 360, 1, 5, 4),
(98, 23, '2020-06-11', 52, 1, 3, 5),
(122, 27, '2020-06-12', 401, 1, 5, 4),
(229, 48, '2020-06-27', 595, 1, 1, 3),
(276, 55, '2020-07-03', 260, 0, 5, 4),
(194, 40, '2020-06-23', 419, 1, 3, 5),
(186, 38, '2020-06-20', 595, 0, 1, 3),
(208, 43, '2020-06-25', 452, 1, 3, 5),
(40, 12, '2020-05-30', 247, 1, 1, 3),
(35, 11, '2020-05-29', 49, 1, 5, 4),
(316, 64, '2020-07-15', 99, 1, 2, 6),
(42, 12, '2020-05-30', 12, 1, 1, 3),
(46, 13, '2020-06-01', 26, 0, 3, 5),
(242, 50, '2020-07-01', 379, 0, 2, 7),
(324, 58, '2020-07-15', 493, 1, 5, 4),
(51, 14, '2020-06-02', 137, 1, 2, 6),
(168, 35, '2020-06-17', 580, 0, 1, 3),
(187, 38, '2020-06-20', 593, 1, 1, 3),
(31, 10, '2020-05-27', 260, 0, 5, 4),
(7, 3, '2020-05-21', 247, 1, 1, 3),
(217, 45, '2020-06-26', 137, 1, 2, 6),
(326, 58, '2020-07-15', 700, 1, 5, 4),
(53, 15, '2020-06-03', 234, 1, 5, 4),
(285, 59, '2020-07-08', 26, 1, 5, 4),
(265, 46, '2020-07-03', 192, 1, 2, 7),
(70, 16, '2020-06-04', 12, 1, 1, 3),
(322, 58, '2020-07-15', 234, 1, 5, 4),
(292, 60, '2020-07-10', 192, 1, 2, 7),
(318, 67, '2020-07-16', 52, 1, 3, 5),
(221, 45, '2020-06-26', 379, 1, 2, 6),
(196, 41, '2020-06-24', 137, 1, 2, 6),
(183, 36, '2020-06-19', 183, 1, 5, 4),
(117, 26, '2020-06-12', 137, 1, 2, 6),
(291, 59, '2020-07-08', 260, 0, 5, 4),
(282, 57, '2020-07-07', 593, 0, 1, 3),
(156, 34, '2020-06-17', 496, 1, 5, 4),
(119, 27, '2020-06-12', 493, 0, 5, 4),
(1, 4, '2020-05-21', 30, 1, 3, 5),
(170, 35, '2020-06-17', 42, 1, 1, 3),
(307, 63, '2020-07-09', 452, 1, 3, 5),
(79, 19, '2020-06-05', 295, 1, 5, 4),
(52, 14, '2020-06-02', 99, 1, 2, 6),
(94, 22, '2020-06-11', 247, 1, 1, 3),
(48, 14, '2020-06-02', 192, 1, 2, 6),
(319, 67, '2020-07-16', 452, 1, 3, 5),
(111, 25, '2020-06-10', 49, 0, 5, 4),
(313, 66, '2020-07-14', 590, 1, 1, 3),
(130, 29, '2020-06-13', 247, 1, 1, 3),
(15, 6, '2020-05-23', 247, 1, 1, 3),
(18, 7, '2020-05-25', 52, 1, 3, 5),
(309, 63, '2020-07-09', 587, 1, 3, 5),
(236, 51, '2020-06-30', 452, 1, 3, 5),
(30, 10, '2020-05-27', 49, 1, 5, 4),
(62, 17, '2020-06-04', 308, 1, 2, 5),
(205, 42, '2020-06-24', 354, 1, 5, 4),
(37, 11, '2020-05-29', 36, 0, 5, 4),
(23, 8, '2020-05-26', 137, 1, 2, 6),
(203, 42, '2020-06-24', 401, 1, 5, 4),
(63, 17, '2020-06-04', 152, 1, 2, 5),
(212, 44, '2020-06-25', 590, 1, 1, 3),
(93, 22, '2020-06-11', 249, 1, 1, 3),
(297, 61, '2020-07-10', 26, 1, 5, 4),
(275, 55, '2020-07-03', 354, 1, 5, 4),
(298, 61, '2020-07-10', 493, 1, 5, 4),
(302, 61, '2020-07-10', 354, 1, 5, 4),
(172, 35, '2020-06-17', 12, 0, 1, 3),
(304, 62, '2020-07-09', 590, 1, 1, 3),
(246, 52, '2020-07-01', 360, 1, 5, 4),
(240, 50, '2020-07-01', 192, 1, 2, 7),
(199, 41, '2020-06-24', 99, 1, 2, 6),
(274, 55, '2020-07-03', 700, 1, 5, 4),
(267, 46, '2020-07-03', 379, 1, 2, 7),
(163, 30, '2020-06-18', 52, 1, 3, 5),
(176, 37, '2020-06-19', 99, 1, 2, 6),
(272, 55, '2020-07-03', 401, 1, 5, 4),
(50, 14, '2020-06-02', 152, 1, 2, 6),
(59, 15, '2020-06-03', 260, 1, 5, 4),
(132, 28, '2020-06-16', 14, 1, 3, 5),
(312, 65, '2020-07-14', 419, 1, 3, 5),
(201, 42, '2020-06-24', 493, 1, 5, 4),
(134, 28, '2020-06-16', 52, 1, 3, 5),
(190, 38, '2020-06-20', 12, 1, 1, 3),
(248, 52, '2020-07-01', 681, 1, 5, 4),
(27, 9, '2020-05-28', 249, 0, 1, 3),
(251, 52, '2020-07-01', 354, 1, 5, 4),
(101, 24, '2020-06-10', 192, 1, 2, 6),
(118, 26, '2020-06-12', 99, 1, 2, 6),
(73, 18, '2020-06-05', 52, 1, 3, 6),
(164, 30, '2020-06-18', 452, 1, 3, 5),
(99, 23, '2020-06-11', 419, 1, 3, 5),
(76, 19, '2020-06-05', 234, 1, 5, 4),
(84, 19, '2020-06-05', 183, 1, 5, 4),
(232, 48, '2020-06-27', 580, 1, 1, 3),
(8, 3, '2020-05-21', 12, 1, 1, 3),
(113, 25, '2020-06-10', 258, 1, 5, 4),
(153, 34, '2020-06-17', 493, 1, 5, 4),
(277, 56, '2020-07-07', 52, 1, 3, 5),
(10, 5, '2020-05-22', 152, 1, 2, 6),
(268, 55, '2020-07-03', 234, 1, 5, 4),
(67, 16, '2020-06-04', 247, 1, 1, 3),
(256, 49, '2020-06-30', 12, 1, 1, 3),
(283, 59, '2020-07-08', 725, 0, 5, 4),
(121, 27, '2020-06-12', 335, 0, 5, 4),
(330, 58, '2020-07-15', 260, 1, 5, 4),
(280, 56, '2020-07-07', 587, 1, 3, 5),
(215, 44, '2020-06-25', 247, 0, 1, 3),
(109, 25, '2020-06-10', 183, 1, 5, 4),
(77, 19, '2020-06-05', 360, 1, 5, 4),
(152, 33, '2020-06-17', 379, 1, 2, 6),
(327, 58, '2020-07-15', 183, 1, 5, 4),
(314, 66, '2020-07-14', 593, 0, 1, 3),
(209, 43, '2020-06-25', 419, 1, 3, 5),
(86, 20, '2020-06-06', 345, 1, 1, 3),
(166, 30, '2020-06-18', 597, 1, 3, 5),
(126, 27, '2020-06-12', 260, 1, 5, 4),
(223, 47, '2020-06-26', 493, 1, 5, 4),
(160, 34, '2020-06-17', 260, 1, 5, 4),
(174, 37, '2020-06-19', 192, 0, 2, 6),
(181, 36, '2020-06-19', 496, 1, 5, 4),
(100, 23, '2020-06-11', 14, 1, 3, 5),
(200, 41, '2020-06-24', 379, 1, 2, 6),
(204, 42, '2020-06-24', 183, 1, 5, 4),
(110, 25, '2020-06-10', 354, 1, 5, 4),
(175, 37, '2020-06-19', 578, 0, 2, 6),
(33, 10, '2020-05-27', 258, 1, 5, 4),
(136, 28, '2020-06-16', 419, 1, 3, 5),
(107, 25, '2020-06-10', 335, 1, 5, 4),
(97, 23, '2020-06-11', 26, 1, 3, 5),
(162, 30, '2020-06-18', 26, 1, 3, 5),
(150, 33, '2020-06-17', 578, 1, 2, 6),
(310, 65, '2020-07-14', 52, 1, 3, 5),
(71, 18, '2020-06-05', 383, 0, 3, 6),
(237, 51, '2020-06-30', 419, 1, 3, 5),
(90, 21, '2020-06-09', 26, 1, 3, 5),
(85, 20, '2020-06-06', 247, 1, 1, 3),
(195, 40, '2020-06-23', 597, 0, 3, 5),
(241, 50, '2020-07-01', 99, 1, 2, 7),
(13, 6, '2020-05-23', 197, 1, 1, 3),
(311, 65, '2020-07-14', 452, 1, 3, 5),
(303, 61, '2020-07-10', 260, 0, 5, 4),
(137, 28, '2020-06-16', 597, 0, 3, 5),
(20, 7, '2020-05-25', 37, 1, 3, 5),
(233, 48, '2020-06-27', 247, 0, 1, 3),
(206, 42, '2020-06-24', 260, 1, 5, 4),
(253, 49, '2020-06-30', 590, 1, 1, 3),
(116, 26, '2020-06-12', 379, 1, 2, 6),
(264, 46, '2020-07-03', 137, 0, 2, 7),
(231, 48, '2020-06-27', 593, 0, 1, 3),
(25, 9, '2020-05-28', 145, 1, 1, 3),
(124, 27, '2020-06-12', 354, 1, 5, 4),
(260, 53, '2020-07-02', 587, 1, 3, 5),
(28, 9, '2020-05-28', 12, 1, 1, 3),
(157, 34, '2020-06-17', 401, 1, 5, 4),
(294, 60, '2020-07-10', 379, 0, 2, 7),
(66, 16, '2020-06-04', 145, 0, 1, 3),
(133, 28, '2020-06-16', 26, 1, 3, 5),
(191, 40, '2020-06-23', 26, 1, 3, 5),
(43, 13, '2020-06-01', 279, 1, 3, 5),
(88, 20, '2020-06-06', 12, 1, 1, 3),
(114, 26, '2020-06-12', 192, 1, 2, 6),
(235, 51, '2020-06-30', 52, 1, 3, 5),
(197, 41, '2020-06-24', 192, 1, 2, 6),
(115, 26, '2020-06-12', 435, 1, 2, 6),
(182, 36, '2020-06-19', 401, 1, 5, 4),
(261, 54, '2020-07-02', 590, 1, 1, 3),
(41, 12, '2020-05-30', 249, 1, 1, 3),
(120, 27, '2020-06-12', 360, 1, 5, 4),
(44, 13, '2020-06-01', 30, 1, 3, 5),
(263, 54, '2020-07-02', 12, 1, 1, 3),
(180, 36, '2020-06-19', 335, 1, 5, 4),
(16, 6, '2020-05-23', 12, 1, 1, 3),
(91, 21, '2020-06-09', 52, 1, 3, 5),
(289, 59, '2020-07-08', 183, 1, 5, 4),
(226, 47, '2020-06-26', 183, 0, 5, 4);

-- хронология занятий:
SELECT 
    attendance_id AS "ID", 
    event_id AS "Урок", 
    event_date AS "Дата", 
    customer_id AS "Ученик", 
    is_attend AS "Был/Нет", 
    group_ids AS "Группа", 
    teacher_ids AS "Преподаватель" 
FROM school ORDER BY event_date;

-- всего: групп, преподавателей, учеников:
SELECT 
    COUNT(DISTINCT group_ids) AS "Групп",
    COUNT(DISTINCT teacher_ids) AS "Преподавателей",
    COUNT(DISTINCT customer_id) AS "Учеников"
FROM school;
    
-- средняя посещаемость:
SELECT event_id AS "Урок", event_date AS "Дата", ROUND(AVG(is_attend::numeric) * 100, 1) AS "Ср.посещаемость"
FROM school
GROUP BY event_id, event_date ORDER BY event_id, event_date;

-- 10 учеников больше всех пропустивших:
SELECT customer_id AS "Ученик",COUNT(*) AS "Кол-во пропусков"
FROM school
WHERE is_attend = 0 GROUP BY customer_id ORDER BY "Кол-во пропусков" DESC LIMIT 10;

-- 5 учеников больше всех пропустивших с указанием даты:
WITH missed_lessons AS (
    SELECT customer_id, COUNT(*) AS missed_count FROM school
    WHERE is_attend = 0 GROUP BY customer_id ORDER BY missed_count DESC
    LIMIT 5
)
SELECT s.event_id AS "Пропущен урок", s.event_date AS "Дата", s.customer_id AS "Ученик", s.group_ids AS "Группа",s.teacher_ids AS "Преподаватель"
FROM school s
JOIN missed_lessons ml ON s.customer_id = ml.customer_id
WHERE s.is_attend = 0 ORDER BY (missed_count, s.customer_id, s.event_date) asc; 
by

PostgreSQL online editor

Write, Run & Share PostgreSQL queries online using OneCompiler's PostgreSQL online editor and compiler for free. It's one of the robust, feature-rich online editor and compiler for PostgreSQL. Getting started with the OneCompiler's PostgreSQL editor is really simple and pretty fast. The editor shows sample boilerplate code when you choose database as 'PostgreSQL' and start writing queries to learn and test online without worrying about tedious process of installation.

About PostgreSQL

PostgreSQL is a open source relational database system and is also knows as Postgres.

Key Features:

  • Postgres is not only free and open-source but also it is highly extensible.
  • Custom Data types and funtions from various programming languaues can be introduced and the good part is compiling entire database is not required.
  • ACID(Atomicity, Consistency, Isolation, Durability) compliant.
  • First DBMS which implemented Multi-version concurrency control (MVCC) feature.
  • It's the default database server for MacOS.
  • It supports all major operating systems like Linux, Windows, OpenBSD,FreeBSD etc.

Syntax help

1. CREATE

CREATE command is used to create a table, schema or an index.

Syntax:

         CREATE TABLE table_name (
                column1 datatype,
                column2 datatype,
                ....);

2. ALTER

ALTER command is used to add, modify or delete columns or constraints from the database table.

Syntax

ALTER TABLE Table_name ADD column_name datatype;

3. TRUNCATE:

TRUNCATE command is used to delete the data present in the table but this will not delete the table.

Syntax

TRUNCATE table table_name;

4. DROP

DROP command is used to delete the table along with its data.

Syntax

DROP TABLE table_name;

5. RENAME

RENAME command is used to rename the table name.

Syntax

ALTER TABLE table_name1 RENAME to new_table_name1; 

6. INSERT

INSERT Statement is used to insert new records into the database table.

Syntax

INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);

7. SELECT

Select statement is used to select data from database tables.

Syntax:

SELECT column1, column2, ...
FROM table_name; 

8. UPDATE

UPDATE statement is used to modify the existing values of records present in the database table.

Syntax

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition; 

9. DELETE

DELETE statement is used to delete the existing records present in the database table.

Syntax

DELETE FROM table_name where condition;