title: Pyspark - saveAsTable - How to Insert new data to existing table?
body: <p><strong>How to Insert new data to existing table???</strong></p>
  
  <p>I'm trying to insert new data to existing table using pyspark.</p>
  
  <p>This is my program</p>
  
  <pre><code>from pyspark import SparkContext
  from pyspark.sql import SQLContext, DataFrameWriter
  
  sc = SparkContext("local[*]", "SPARK-SQL")
  sqlContext = SQLContext(sc)
  
  df = sqlContext.read.json("people.json")
  df.registerTempTable("people")
  
  # Show old data
  result = sqlContext.sql("SELECT * from people")
  result.show()
  
  # Create new data
  new_data = [{"name": "Phan", "age": 22}]
  df_new_data = sqlContext.createDataFrame(new_data)
  # Save data to table 'people'
  df_new_data.write.mode("append").saveAsTable("people")
  
  # Show new data
  result = sqlContext.sql("SELECT * from people")
  result.show()
  </code></pre>
  
  <p>After I run it. Data in table "people" can not be changed. </p>
  
  <pre><code>Old data
  +---+--------+
  |age|    name|
  +---+--------+
  | 30| Michael|
  | 30|    Andy|
  | 19|  Justin|
  | 21|PhanHien|
  +---+--------+
  New data
  +---+--------+                                                                  
  |age|    name|
  +---+--------+
  | 30| Michael|
  | 30|    Andy|
  | 19|  Justin|
  | 21|PhanHien|
  +---+--------+
  </code></pre>
  
  <p>Please help me to change data in table!!!
  Thank you!</p>