EVA
EVADec. 24, 2023, 9:39 p.m.

DDL SQL Commands Cheat Sheet

1. CREATE TABLE

  • Purpose : Creates a new table in the database.
  • Syntax :
    CREATE TABLE table_name (
          column1 datatype,
          column2 datatype,
          column3 datatype,
          ...
      );
  • Example :
    CREATE TABLE Employees (
          EmployeeID int,
          FirstName varchar(255),
          LastName varchar(255),
          BirthDate date
      );

2. ALTER TABLE

  • Purpose : Modifies an existing table (e.g., adding a column).
  • Syntax :
    ALTER TABLE table_name ADD column_name datatype;
  • Example :
    ALTER TABLE Employees ADD Email varchar(255);

3. DROP TABLE

  • Purpose : Deletes an existing table in the database.
  • Syntax :
    DROP TABLE table_name;
  • Example :
    DROP TABLE Employees;

4. TRUNCATE TABLE

  • Purpose : Removes all data from a table, but not the table itself.
  • Syntax :
    TRUNCATE TABLE table_name;
  • Example :
    TRUNCATE TABLE Employees;

5. CREATE INDEX

  • Purpose : Creates an index on a table column for faster retrieval of data.
  • Syntax :
    CREATE INDEX index_name ON table_name (column1, column2, ...);
  • Example :
    CREATE INDEX idx_lastname ON Employees (LastName);

6. DROP INDEX

  • Purpose : Deletes an index from a table.
  • Syntax :
    DROP INDEX index_name ON table_name;
  • Note: Syntax may vary slightly depending on the database system.
  • Example :
    DROP INDEX idx_lastname ON Employees;

7. RENAME TABLE

  • Purpose : Renames an existing table.
  • Syntax :
    ALTER TABLE table_name RENAME TO new_table_name;
  • Example :
    ALTER TABLE Employees RENAME TO Staff;

Remember, the exact syntax for these commands can vary slightly depending on the SQL database system (e.g., MySQL, PostgreSQL, SQL Server, etc.). Always refer to the specific documentation for your database system for the most accurate information.

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

Comments

Only authorized users can post comments.
Please, Log in or Sign up
Ua

Qt - Test 001. Signals and slots

  • Result:84points,
  • Rating points4
Ua

Qt - Test 001. Signals and slots

  • Result:42points,
  • Rating points-8
ОК

Qt - Test 001. Signals and slots

  • Result:47points,
  • Rating points-6
Last comments
ИМ
Игорь МаксимовNov. 22, 2024, 9:51 p.m.
Django - Tutorial 017. Customize the login page to Django Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильн…
Evgenii Legotckoi
Evgenii LegotckoiOct. 31, 2024, 11:37 p.m.
Django - Lesson 064. How to write a Python Markdown extension Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup
A
ALO1ZEOct. 19, 2024, 5:19 p.m.
Fb3 file reader on Qt Creator Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html
ИМ
Игорь МаксимовOct. 5, 2024, 4:51 p.m.
Django - Lesson 064. How to write a Python Markdown extension Приветствую Евгений! У меня вопрос. Можно ли вставлять свои классы в разметку редактора markdown? Допустим имея стандартную разметку: <ul> <li></li> <li></l…
d
dblas5July 5, 2024, 8:02 p.m.
QML - Lesson 016. SQLite database and the working with it in QML Qt Здравствуйте, возникает такая проблема (я новичок): ApplicationWindow неизвестный элемент. (М300) для TextField и Button аналогично. Могу предположить, что из-за более новой верси…
Now discuss on the forum
AH
Abdul HadiFeb. 13, 2025, 3:21 p.m.
Are you Looking for best painter services in Qatar? Looking for top painter Services in Qatar? Get high-quality, affordable, and professional painting for homes & offices. Contact expert painters today!
d
dubaicushionsFeb. 13, 2025, 3:17 p.m.
Are Looking for custom swing cushions in Dubai for home decor? Looking for Custom Swing Cushions in Dubai? Get high-quality, weather-resistant, and stylish cushions for your outdoor swing. Order now for comfort & elegance!
d
dubaicustomizedsofaFeb. 13, 2025, 3:11 p.m.
Are you Looking for a custom sofa in Dubai? Looking for a Custom Sofa in Dubai ? Get high-quality, stylish, and tailor-made sofas to match your space. Order now for comfort, luxury, and perfect design!
b
blinds12Feb. 11, 2025, 4:08 p.m.
Why Bamboo Blinds Are the Perfect Choice for Your Home When it comes to enhancing the aesthetics and functionality of your living space, choosing the right window treatment is crucial. Bamboo blinds have emerged as a popular choice for homeowners wh…
i
imperial3130Feb. 11, 2025, 3:40 p.m.
How to Select the Right Carpet for Your Bedroom Aesthetic Choosing the perfect carpet for your bedroom involves more than just picking a color or pattern you like. Carpets can transform the ambiance of your space, adding warmth, comfort, and style. How…

Follow us in social networks