stamin4
  • whoami
  • HTB Academy
    • Introduction to Academy
    • Learning Process
    • Vulnerability Assessment
    • Web Requests
    • Introduction to Networking
    • Linux Fundamentals
    • Brief Intro to Hardware Attacks
    • Setting Up
    • Using the Metasploit Framework
    • Security Incident Reporting
    • Introduction to Web Applications
    • JavaScript Deobfuscation
    • Attacking Web Applications with Ffuf
    • Windows Fundamentals
    • File Inclusion
  • HTB Machines
    • Windows
      • 🟢Easy
      • 🟠Medium
      • 🔴Difficult
      • 🟣Insane
    • Linux
      • 🟢Easy
        • Cap
      • 🟠Medium
      • 🔴Difficult
      • 🟣Insane
  • OverTheWire
    • Bandit
      • Nivel 0
      • Nivel 1
      • Nivel 2
      • Nivel 3
      • Nivel 4
      • Nivel 5
      • Nivel 6
      • Nivel 7
      • Nivel 8
      • Nivel 9
      • Nivel 10
  • Base de datos
    • SQL
      • SELECT queries 101
      • Queries with constraints (Pt. 1)
      • Queries with constraints (Pt. 2)
      • Filtering and sorting Query results
      • Simple SELECT Queries
      • Multi-table queries with JOINs
      • OUTER JOINs
      • A short note on NULLs
      • Queries with expressions
      • Queries with aggregates (Pt. 1)
      • Queries with aggregates (Pt. 2)
      • Order of execution of a Query
      • Inserting rows
      • Updating rows
      • Deleting rows
      • Creating tables
      • Altering tables
      • Dropping tables
  • PortSwigger
    • Path Traversal
  • Dockerlabs
    • Trust
    • Firsthacking
    • Upload
Powered by GitBook
On this page
  1. Base de datos
  2. SQL

Altering tables

SQL Lesson 17

ALTER TABLE permite añadir, eliminar o modificar columnas de una tabla.

  • Añadir columnas:

ALTER TABLE mytable 
ADD column DataType OptionalTableConstraint 
	DEFAULT default_value;
  • Eliminar columnas (no soportado por SQLite):

ALTER TABLE mytable 
DROP column_to_be_deleted;
  • Renombrar tabla:

ALTER TABLE mytable 
RENAME TO new_table_name;

  1. Agregue una columna llamada aspect_ratio de tipo FLOAT para almacenar la relación de aspecto en la que se lanzó cada película.

ALTER TABLE movies
ADD aspect_ratio FLOAT;
  1. Agregue otra columna denominada language de tipo TEXT para almacenar el idioma en el que se estrenó la película. Asegúrese de que el idioma predeterminado sea el inglés.

ALTER TABLE movies
ADD language TEXT DEFAULT English;
PreviousCreating tablesNextDropping tables

Last updated 1 year ago